Regex: How to match a specific tag name?

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,920
I've ran into an issue with , which doesn't ensure the tag name is an exact match, which results in it seeing mj-image being the same as mj-image-variable, since all it's looking for is <mj-image*.

Here's the specific line of code causing the issue:

I want to the regular expression to ensure an exact match of the tag name, with the following scenarios in mind:
1. No attributes.
2. Has attributes, on the same line.
3. Has attributes, but on a different line.

Here's a regex101:

Here's what you can do to match #2 and #3:
 
Solution
Here's what I was looking for, which covers all of the scenarios I described:
Code:
<mj-image((?:[ \n][^>]*)?)>([^]*?)<\/mj-image>

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,920
Here's what I was looking for, which covers all of the scenarios I described:
Code:
<mj-image((?:[ \n][^>]*)?)>([^]*?)<\/mj-image>

 
Solution

Users who are viewing this thread

Top