[PerlChina] wanna a regex expression

Havel Zhang havel.zhang at gmail.com
Wed Aug 23 22:18:50 PDT 2006


hi wanliyou:
  don't set it as global, may ignore the last replacement.
yang wang to change 'how are you today ? "are you ok?" you are welcome!'     to
' how are hello today? "are you ok?" hello are welcome!'
if you not using global, the last 'you' will be ignored.

Havel Zhang



On 8/24/06, …d„^…d <wanliyou at gmail.com> wrote:
>
> ~s# # #g
>
> ~s# # #
>
> Don't set it as global may help
>
>
> On 8/23/06, Havel Zhang <havel.zhang at gmail.com> wrote:
> >
> >  hi yang:
> >
> >     you can using (?!...) regex extension solve this problem. like
> > follows:
> > #---------------------
> > $a = 'how are you today ? "are you ok?" you are welcome!';
> > $a =~ s/you(?!\sok\?)/hello/ig;
> > print $a ."\n";
> > #-------------------
> > Outputs:
> >  how are hello today ? "are you ok?" hello are welcome!
> >  #-------------------
> >
> >
> > other regEx extensions:
> >
> > (?= ... ) if  match ahead successfully, return true.
> > (?!  ... ) if  match ahead failed, return true.
> > (?<= ...) if match backwards successfully, return true.
> > (?<! ... ) if match backwards failed, return true.
> >
> > Good, luck. :)
> >
> > Havel Zhang
> >
> >  On 8/23/06, ÑîÏþÁÁ < yang.liana at gmail.com> wrote:
> >
> > >        Hi, all!
> >      suppose a src string like this: how are you today ? "are you ok?"
> > you are welcome!
> >      I want this string to be       : how are hello today? "are you ok?"
> > hello are welcome!
> >
> >      I want to use just a regex express to do it. but i cant prevent
> > from "are you ok?" being changed to be "are hello ok?".
> >      I want to use the *Look ahead* or *Look behind* to solve it. can I
> > ?
> >
> > Yang.liana
> > Aug/23/2006
> >
> > _______________________________________________
> > China-pm mailing list
> > China-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/china-pm
> >
> >
> >
> >
> > --
> > ÕæÀíʹÄã×ÔÓÉ
> >
> > _______________________________________________
> > China-pm mailing list
> > China-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/china-pm
> >
>
>
>
> --
> --==Best Regards From WanLi==--
>
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm
>



-- 
ÕæÀíʹÄã×ÔÓÉ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/china-pm/attachments/20060824/90041120/attachment.html 


More information about the China-pm mailing list