Perl regexp / (\ r \ n | \ r | \ n) /

I want to know how this ambiguous pattern is solved in perl (in general, everything that libpcre uses):

/(\r\n|\r|\n)/

When the pattern sees \r\n, will it match once or twice? And what are the rules facing this situation?

thank

+3
source share
4 answers

It will match \r\nonce since Perl uses a regex engine that looks forward to change. See here .

, , , , . / , , . , regex regex|regex not regex not. - regex, . regex not, . , , , "".

+7

, , . , "\r\n", . .

+1

... perl ( , , libpcre)

: Perl libpcre. PCRE , Perl Perl. PHP ActionScript libpcre, "Perl-" (, Python, Java .NET) .

, : , , , .

+1

He will match him once. More details here: http://technocage.com/~caskey/dos2unix/

0
source

Source: https://habr.com/ru/post/1756957/


All Articles