For new users, please refer to the following questions about reverse reference of regular expressions: Hello, everyone! I'm a Cainiao. I have something to ask. I recently read "Let's talk about PHP" and read it in a book. each subexpression in a regular expression (included in ), when no non-capturing metacharacters are added, they are stored in the buffer according to the matching results of each sub-expression from left to right and referenced by numbers 1 to 99, I don't know if this is the correct description. There are two problems: 1. The book says that if you use a number to reference a subexpression, you need to add a reversed expression before the number.
Dear elders! I'm a Cainiao. I have something to ask.
I recently read "Let's talk about PHP" and read it in a book. each subexpression in a regular expression (included in ), when no non-capturing metacharacters are added, they are stored in the buffer according to the matching results of each sub-expression from left to right and referenced by numbers \ 1 to \ 99, I don't know if this is the correct description. There are two problems:
1. The book says that using a serial number to reference a subexpression requires a backslash before the serial number to escape the subexpression. This article is very tangled and I don't need it. is it related to any version?
2. is a subexpression added with a metacharacter? :. In this way, the matching results will not be stored, so the number of the buffer will not be added, and no number can be referenced. can this subexpression be called repeatedly?
Thank you!
------ Solution --------------------
What does repeated call and reference mean? If so, do you know the answer.
------ Solution --------------------
/^ ([A-zA-Z] *) \ d + \ 1 $/
This is not
Add backslash escape before the number?
Is that what you mean by the second question?
/^ (? = [A-zA-Z] +) \ d + (? = [A-zA-Z] +) $/