I would just like to ask some help in constructing a regex formula for this example:
Brgy. Captain : Kgg. Constancia M. Reyes\nKagawad : Kgg. Henry A. Artisen\n Kgg. Juliana S. Santos\n Kgg. Sonia C. Alzona\n Kgg. Fernandito L. Perez\n Kgg. Ismael V. Capunitan\n Kgg. Gregoria R. Sanchez\n Kgg. Nerisa Maristañes
I am using Java in Ecplise IDE. I just would like to get the all the councilor names and then ignore all preceding and succeeding characters. This is what I would like to get:
Is this possible in the first place?
I tried using this regex as i have a google chrome app then can test a regex formula but failed to match it: (Brgy. Captain :).\\\\n+(Kagawad :).\\\\n+
如果它将始终是Kgg
,那么这应该起作用:
(Kgg.*?)(?=\\n)
The answer provided by Justin Pihony matches all of the given councilor names, but the last one. Maybe you tried to remove everything that matches instead of preserving.
(\\n.*?)(?=Kgg)
This one is the opposite. It matches everything between. But for it to work you have to add another \\n to the beginning of the list.
For eclipse I can recommend you the following plug-in for very fast testing of regular expressions: http://myregexp.com/eclipsePlugin.html
And for basic understanding of regular expressions: http://www.regular-expressions.info/reference.html
HTH
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.