Hi in my program a string is generated like "1&area_id=54&cid=3".First an integer and then a string "&area_id=",then antoher integer, and after that a string “&cid=” and then the final integer.These two strings are always same.But integer is changing.How to write split function so that i can find these three integers in three variable or with in an array.I can seperate these by looping but i want to use split function.Thanks
Hi in my program a string is generated like 1&area_id=54&cid=3 .First an integer and
Share
How about
This works with your example:
outputs
The call to
string.split("&\\w+=")reads in English: Splitstringon every match for the regular expression parameter, and then return all substrings in between the matched tokens as an array.The regular expression reads: Match all substrings starting with
"&", followed by at least ("+") one word-character ("\\w", i.e. letters, digits, and some special characters, such as the underscore from your example), followed by"=". For more details see the Javadoc forjava.util.regex.Pattern