My pattern works in JavaScript.
(?<=(?:username|Email|URL)(?:\s|:))[^\n]+
However, when I try to use it in PHP, I get this error:
A lookbehind assertion has to be fixed width
How I can fix it?
Demo: https://regex101.com/r/x2W3S5/1
>Solution :
Use a full string match restart (\K) instead of the invalid variable-length lookbehind.
(?:username|Email|Url):? *\K[^\v]+
Make the colon and space optional by trailing them with ? or *.
See also: Variable-length lookbehind-assertion alternatives for regular expressions