[ale] OT Java Regular expression question

Mike Millson mgm at atsga.com
Thu Oct 3 15:41:29 EDT 2002


. ("dot") does not match linefeeds by default. You have to enable DOTALL
mode on your pattern. I haven't done this, but I added a line below of
something you may try (RE.DOTALL).

Mike

-----Original Message-----
From: Jim Lynch [mailto:jwl at sgi.com]
To: ale at ale.org
Sent: Thursday, October 03, 2002 1:57 PM
To: Ale
Subject: [ale] OT Java Regular expression question


Does anyone know how to do a greedy match across newlines in java REs?

For instance:

text = "xxxabc123xyzxxx";
RE pattern = "abc(.*?)xyz";

RE.DOTALL;

newtext = pattern.substitute("NEW");

System.out.println(newtext);

Outputs xxxNEWxxx
But fails if text="xxxabc\n123xyzxxx";

substituteAll doesn't work either.  Perl of course requires the /g
option and python has something equivalent, but I haven't figured out
what the java equivalent is.

Any ideas?

Thanks,
Jim.

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.



---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list