In article <09420b4c-2d19-4f07-ba9f-5d5a7ce1e26d@i20g2000prf.googlegroups.com>,
Arun <setsun@gmail.com> wrote:
On Dec 29, 8:29 pm, "John B. Matthews" <nos...@nospam.com> wrote:[...]
<http://java.sun.com/docs/books/tutorial/essential/regex/>
What syntax errors did this approach discover?
[Please trim sigs.]
I think I did not explain my requirement.
I have 3 lines
LINE 1 -> :61:0112201223CD110,92NDIVNONREF//08 IL053309
LINE 2 -> /GB/2542049/SHS/312,
LINE 3 -> :62F:C011021USD175879,84
And I grab line 1 & 2 using pattern "(:61:.*?.[^:]+)" and copy it to
a StringBuffer. Now, with matcher.group(int arg) function, i need to
group the sequence so that i can get the 2nd line.
matcher1.group(1) should return :61:0112201223CD110,92NDIVNONREF//08 IL053309 ( along with the \n ) and matcher1.group(2) should return /GB/ 2542049/SHS/312,[...]
You could try matching the \n:
Pattern p = Pattern.compile("(^.*\n)(.*\n)", Pattern.DOTALL);
Matcher m = p.matcher(s);
if (m.matches()) ...
Again, an <http://sscce.org/> would make discussion easier.
[Please trim sigs.]
--
John B. Matthews
trashgod at gmail dot com
http://home.roadrunner.com/~jbmatthews/
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 286 |
Nodes: | 16 (2 / 14) |
Uptime: | 86:57:01 |
Calls: | 6,496 |
Calls today: | 7 |
Files: | 12,099 |
Messages: | 5,277,134 |