Jeremy Rayner on java and other stuff.

All | AudioDrama | Chatter | Fun | Groovy | Java | Life

A Java Regular Expression...
Posted on 10 Sep 2004
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

10 Sep 2004 |

 

 
September 2004
SunMonTueWedThuFriSat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
Prev | Today | Next

rss:subscribe (All)



What I'm reading
my feed aggregator ->box

My websites
London Java Meetups
Programming Projects
Elite in Java
megg
Blogmento
Jez's Photos
Fantasy Stock Market
Cool Saxophonist
Doctor Who Audios
Pisces Audios

Other Blogs
Mike Cannon-Brookes
James Strachan
Joe Walnes
Sam Dalton
Simon Brown
Cameron Purdy
Mike Roberts
Erik C. Thauvin
John Martin
Manfred Riem

B5 d++ t++ k s+ u- f
i+ o+ x-- e+ l- c--

powered by blogmento