lundi 16 mai 2022

Want to parse a string only want specific parts in the string using regex

The string essentially must longer so I shortened it bit:

   String s1= ("henry2O|*|bob10|*|mark20|*|justin30|*|kyle15|*|95|*|henry3O|*|bob50|*|mark70|*|justin30|*|kyle25|*|1000|");

So essentially it follows this pattern and keeps repeating so I essentially want only want the parts with henry, mark, kyle, and all the numbers so in this case 95,1000 left. Not too sure of good way to use regex to achieve this.

Essentially I want my output to be:

(henry20,mark20,kyle15,95,henry30,mark70,kyle25,1000)

Aucun commentaire:

Enregistrer un commentaire