2

I have such input string:

left/1234567890

regular expression:

(left(?<=/)[0-9]{10}?)

I want to get such result: 1234567890. But it doesn't work.

Although, the next input string:

/1234567890

with the next regular expression:

((?<=/)[0-9]{10}?)

get result as expected: 1234567890.

1 Answer 1

6

This is because you did not include left into your lookbehind:

((?<=left/)[0-9]{10}?)

In your first example, you match left then the regex engine's 'pointer' is between t and /, so your lookbehind cannot match, because the regex engine has not passed the slash yet.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.