I have html tags like bellow
<id>1234-12</id>
<id>12345-123</id>
<id>123</id>
<id>12345</id>
<id>12346</id>
I want to find all numbers between <id> </id> that has hyphens
exampple
<id>1234-12</id>
<id>12345-123</id>
this will find all between tag
<id>. ?<\/id>
but how to find only numbers with hyphens Thanks!
CodePudding user response:
If you want to find only numbers with a hyphen in between:
<id>\K\d -\d (?=<\/id>
Explanation
<id>
Match literally\K
Forget what is matched so far\d -\d
Match-
surrounded by 1 digits(?=<\/id>
Assert</id>
directly to the right