[PerlChina] wanna a regex expression

杨晓亮 yang.liana at gmail.com
Wed Aug 23 22:26:37 PDT 2006


Yes, what I wanted was to use (?!...), (?=...) or (?<=...) and so on to resolve this.
I believe the Power of perl regex expression.
Thank you for the helping of Havel Zhang and Wanliyou :-)

Yang.liana
Aug/24/2006



·¢¼þÈË£º Havel Zhang
·¢ËÍʱ¼ä£º 2006-08-24 13:19:18
ÊÕ¼þÈË£º china-pm at pm.org
³­ËÍ£º 
Ö÷Ì⣺ Re: [PerlChina] wanna a regex expression

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/1bce1fc3/attachment.html 


More information about the China-pm mailing list