Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Regex: How to match a specific tag name?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="RastaLulz" data-source="post: 467213" data-attributes="member: 1"><p>I've ran into an issue with <a href="https://github.com/mjmlio/mjml2json" target="_blank">[ICODE]mjml2json[/ICODE]</a>, which doesn't ensure the tag name is an exact match, which results in it seeing [ICODE]mj-image[/ICODE] being the same as [ICODE]mj-image-variable[/ICODE], since all it's looking for is [ICODE]<mj-image*[/ICODE].</p><p></p><p>Here's the specific line of code causing the issue:</p><p>[URL unfurl="true"]https://github.com/mjmlio/mjml2json/blob/master/src/mjml2json.js#L45[/URL]</p><p></p><p>I want to the regular expression to ensure an exact match of the tag name, with the following scenarios in mind:</p><p>1. No attributes.</p><p>2. Has attributes, on the same line.</p><p>3. Has attributes, but on a different line.</p><p></p><p>Here's a regex101:</p><p>[URL unfurl="true"]https://regex101.com/r/yIUZXf/1[/URL]</p><p></p><p>Here's what you can do to match #2 and #3:</p><p>[URL unfurl="true"]https://regex101.com/r/acM5Ia/1[/URL]</p></blockquote><p></p>
[QUOTE="RastaLulz, post: 467213, member: 1"] I've ran into an issue with [URL="https://github.com/mjmlio/mjml2json"][ICODE]mjml2json[/ICODE][/URL], which doesn't ensure the tag name is an exact match, which results in it seeing [ICODE]mj-image[/ICODE] being the same as [ICODE]mj-image-variable[/ICODE], since all it's looking for is [ICODE]<mj-image*[/ICODE]. Here's the specific line of code causing the issue: [URL unfurl="true"]https://github.com/mjmlio/mjml2json/blob/master/src/mjml2json.js#L45[/URL] 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: [URL unfurl="true"]https://regex101.com/r/yIUZXf/1[/URL] Here's what you can do to match #2 and #3: [URL unfurl="true"]https://regex101.com/r/acM5Ia/1[/URL] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Regex: How to match a specific tag name?
Top