I wan to extract the string from the below line of code
span id="testing" This is testing span a id="test" link a
from the above code I want to extract the id's alone using regex
eg: "testing", "test"
I wan to extract the string from the below line of code
span id="testing" This is testing span a id="test" link a
from the above code I want to extract the id's alone using regex
eg: "testing", "test"
If your identifiers are comprised of word characters only:
this regex works: (?<=id=")\w+(?=")
. The full match is the id. However, this could cause compatibility issue in Safari, that doesn't support lookbehinds ((?<= )
)
You can also use capture groups with id="(\w+)"
. The only captured group will be the id you're looking for.