[Israel.pm] regex question

Shlomi Fish shlomif at iglu.org.il
Tue Jan 5 06:14:56 PST 2010


Hi Yossi!

On Tuesday 05 Jan 2010 14:39:45 Yossi Itzkovich wrote:
> Hi,
> I need to catch a text between, for example, the word "myWord" and a word
>  which is not "myWord". I can do it like : 
>  m~\bmyWord\b(.+?)\b[^m][^y][^W][^o][^r][^d]\b~  but I guess there is a

This regex is wrong. It won't match "byWord", "maWord", "myDord", etc. which 
are all different from "myWord". For more information see:

http://perl.net.au/wiki/Freenode_Sharp_Perl_FAQ#How_can_I_match_anything-
except-a-regex_inside_a_Perl_regular_expression.3F

(short URL - http://xrl.us/bgr2ec ).

You can try a lookahead match, or you can try using /g and \G etc for 
incremental matches.

Regards,

	Shlomi Fish

>  much better alternative.
> 
> Thanks in advance
> 
> Yossi
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
> 

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

Bzr is slower than Subversion in combination with Sourceforge. 
( By: http://dazjorz.com/ )


More information about the Perl mailing list