Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

newbie's regex question

Thread view: 
NPtr - 10 Feb 2007 22:52 GMT
I need to crop all text between one expression(let it be expr1) and the
first match of another(expr2). The text looks like:
 some text expr1 some text expr2 some text expr2.       I know nothing
about length of the text.
The point is that i can't just write expr1(.*)expr2, because the expr2 is
repeated more than one time (and it crops everything before the last match
of expr2 ), but I need the text just before the first match of expr2. Maybe
I can say that "some text" must not contain expr2, but i don't know how to
do this. Help me please.

Thank you in advance.
hiwa - 10 Feb 2007 23:12 GMT
On Feb 11, 7:55 am, "NPtr" <vasya_del....@ussr.ntu-kpi.kiev.ua.del.it>
wrote:
> I need to crop all text between one expression(let it be expr1) and the
> first match of another(expr2). The text looks like:
[quoted text clipped - 7 lines]
>
> Thank you in advance.

Use reluctant quantifiers.
See API doc for Pattern class.
NPtr - 11 Feb 2007 11:35 GMT
> Use reluctant quantifiers.
> See API doc for Pattern class.
Thanks, it works. Sorry for the stupid question.
I thought I had tried these qualifiers, but in fact I hadn't.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.