Page 1 of 1

What does it matches h(?<=a)b

Posted: Sun May 20, 2007 11:36 am
by nwp
According to my knowledge the regex

Code: Select all

h(?<=a)b
should match the text 'hab'
as
It matches teh character 'h' naturally.
then it starts looking behind to find an character 'a'
If it finds the character 'a' then it goes forward and matches the next character that should be 'b'[/syntax]

Posted: Sun May 20, 2007 12:39 pm
by Chris Corbyn
Yes, it will match hab. If the "h" wasn't there it would just match "b".

Posted: Sun May 20, 2007 1:31 pm
by GeertDD
This regex will never ever match anything. When it matches the 'h' it looks back from that position in the hope to find an 'a'. Of course, it will always find that same 'h' and therefore fail.

Posted: Sun May 20, 2007 2:43 pm
by Chris Corbyn
Indeed you're right :oops: