Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use regexp-me library? [closed]

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.

like image 314
Sam YC Avatar asked Nov 12 '22 20:11

Sam YC


1 Answers

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);
like image 87
Michael Donohue Avatar answered Dec 05 '22 19:12

Michael Donohue