昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期二, 四月 01, 2014

regex, how look behind work

Look behind doesn't take space either

Look this example

(?m)(?<=a)bc.(?<=a)bc


it will only match abcabc

the matched string is bcabc


how to read this regex?

Remove the look behind first

it becomes bc.bc

OK, this will match quite a few string, like dbcebc


but, remember we have look behind, that means, before first bc, it must be an a, before second bc, it must be another a there. so....

only abcabc will match.


Look behind add another layer of restriction. easy?

--
Feng

没有评论:

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.