I need to implement the following:
“$prefs” within the string “something something $prefs(something
something)” should be returned. $prefs consists of letters form a-zAz
and digits from 0-9. The “$” is always there.
Finding the beginning of $prefs is no problem, but finding the end is trickier. As described above, $prefs could also be $prefssdf, followed be pretty much anything, like (, ,, &&, and what not.
Is there a way to do something like this:
while(string.elementAt(i) == [a-zA-Z0-9]){
result += string.elementAt(i);
}
An example:
I have following string:
Select * from test where $prefs(select * from test2 where $prefs2);
I need to extract all occurrences of expressions with $ prefixed, so in this case it is $prefs and $prefs2. How do I do that most efficiently?
1 Answer