Answer the question
In order to leave comments, you need to log in
Why does the regular expression "#^\d{1,3}\.#" skip the first element of the string array?
There is an array of strings, each of which can start with a digit and a dot. At the moment, the first element starts like this, but the expression "#^\d{1,3}\.#" skips and finds the rest. And the expression "#\d{1,3}\.#" will find the first element, but it doesn't work, since the numbers with a dot can be in the middle, at the end of unnecessary elements. How to solve the problem?
Answer the question
In order to leave comments, you need to log in
#^\d{1,3}\.# m
m(PCRE_MULTILINE)
By default, PCRE treats data as a single-line character string (even if it contains multiple line separators). The start-of-line meta-character '^' matches only the start of the processed text, while the "end-of-line" metacharacter '$' matches the end of the text, or the position before the final text line feed (if the D modifier is not set). In Perl, the situation is completely similar. If this modifier is used, the "beginning of line" and "end of line" metacharacters also match positions before and after an arbitrary newline and line character, respectively, as well as at the very beginning and at the very end of the line. This corresponds to the /m Perl modifier. If the text being processed does not contain newlines, or the template does not contain metacharacters '^'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question