[PerlChina] wanna a regex expression
Havel Zhang
havel.zhang at gmail.com
Wed Aug 23 04:32:54 PDT 2006
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
>
--
真理使你自由
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/china-pm/attachments/20060823/55d3e99d/attachment.html
More information about the China-pm
mailing list