Regular Expression: Lookahead and Lookbehind

Ever wonder what this regular expression means? “^(?<=PO)abc$”, the parenthesis in the beginning is the “positive lookbehind” as per symble less than. It pretty much check any characters before “abc” that has to equal to “PO” otherwise any expression wont happen. It is like a STOP to the expression and fails if it doesn’t match.

For more information check this link:

https://stackoverflow.com/questions/2973436/regex-lookahead-lookbehind-and-atomic-groups

And also a thorough explanation happening under the hood, this is a good explanation as you follow the paragraph:

https://www.regular-expressions.info/lookaround.html

If you are wondering whether you can put it in any order, yes you can but an explanation is below:

https://stackoverflow.com/questions/2126137/regex-lookahead-ordering

Leave a Reply

Your email address will not be published. Required fields are marked *