<id pathelement="/abc">route</id>
The above html tag I use the following regex to match always unsuccessful:
<(?<id>\w+)\s*(\w+).\"\/\w+\">.*<\/\k<id>>
But it works if I don't specify the group name, like this:
<(\w+)\s*(\w+).\"\/\w+\">.*<\/\1>
do not know why? At the beginning, you still have to digest it slowly.
It's still unclear why, the specified group name really doesn't match. Later, I went to the regular expression bar to ask questions, and a bar friend gave me an enthusiastic answer. Also provided me with a website, http://regex101.com/# for testing regular expressions. This website is really good, not only matching results but also explanations, thank you.
Reprinted in: https://www.cnblogs.com/RainingDays/p/3431969.html