[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] OT Java Regular expression question
- Subject: [ale] OT Java Regular expression question
- From: mgm at atsga.com (Mike Millson)
- Date: Thu, 3 Oct 2002 15:41:29 -0400
. ("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.