The Artima Developer Community
Sponsored Link

Java Buzz Forum
A Java Regular Expression...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeremy Rayner

Posts: 111
Nickname: j6wbs
Registered: Sep, 2003

jez codes stuff
A Java Regular Expression... Posted: Sep 10, 2004 8:39 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Jeremy Rayner.
Original Post: A Java Regular Expression...
Feed Title: javanicus
Feed URL: http://www.javanicus.com/blog2/subjects/java-rss.xml
Feed Description: Jeremy Rayner on java and other stuff.
Latest Java Buzz Posts
Latest Java Buzz Posts by Jeremy Rayner
Latest Posts From javanicus

Advertisement
For my own future reference, a hard fought Java regular expression.
foo(.*?)(?=foo)
This will match all the characters after the first expresion foo, up to but not including the second expression foo

The (.*?) has a lazy quantifier, and will only capture as much as it has to, to make the whole expression match.

The (?=foo) is a non-capturing lookahead, which will not exclude the next foo from being a valid anchor.

i.e. The bold text indicates each match.

   foowibblefoowobblefoojelly on a platefoo

Read: A Java Regular Expression...

Topic: Using Apache mod_rewrite to Shield a Java Web Container from Abuse Previous Topic   Next Topic Topic: A brief list of lost items

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use