I have a string I'm trying to parse with regex that seems to need one part of the string as a part of two different capture groups. Consider the following example:
<!-- 123 text -->text bit 1<!-- /123 text -->
<span class="someclass">something</span>
<!-- 456 text -->222 text<!-- /456 text -->
In this example code, I want three capture groups:
The easiest unique piece of this is the -->
followed by some number, so I thought of starting like this:
(.*-->\d+)
This would correctly find the right area, but I need that first capture group to be without the number and the second to have it. What am I missing?
检查是否适合您
(.*-->)(\d+)(.*)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.