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:
- Kgg. Constancia M. Reyes
- Kgg. Constancia M. Reyes
- Kgg. Juliana S. Santos
- Kgg. Sonia C. Alzona
- Kgg. Fernandito L. Perez
- Kgg. Ismael V. Capunitan
- Kgg. Gregoria R. Sanchez
- Kgg. Nerisa Maristañes
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+
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.
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