I am pretty surprised that when I come across J2ME does not have the normal regex that I have been using in the J2SE.
I found this J2ME supported regex library: regexp-me
Anyone can tell me how to get the starting/ending position or something like matcher.group() (in J2SE), from this library. I can see that it has a boolean return function 'match', but that is not what I want.
Moreover, they use curly bracket with the getParenStart(0) to retrieve the matched regex, but I never use such thing before in J2SE, can't really understand what is it doing.
For example:
regex = a.+b
The string that I want to search in:
kkkkacccb789
I want to know the position of acccb
or preferably get the whole matched string, acccb
out of the string.
It seems like you've already figured it out. This snippet will do the match you want, and put the matching part of the string in the local variable matchedSubstring
RE regex = new RE("a.+b");
r.match("kkkkacccb789");
String matchedSubstring = r.getParen(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With