Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created January 11, 2012 04:05
Show Gist options
  • Save heapwolf/1592949 to your computer and use it in GitHub Desktop.
Save heapwolf/1592949 to your computer and use it in GitHub Desktop.
new RegExp(
[
'<',
'(/?)', // 2 - is closing
'([-:\\w]+)', // 3 - name
'((?:\\s+[-\\w]+(?:', '=', '(?:' +
'\\w+|' +
'"[^"]*"|' +
'\'[^\']*\'))?)*)', // 4 - attributes
'(/?)', // 5 - is self-closing
'>'
].join('\\s*')
)
@heapwolf
Copy link
Author

i want it to allow for / in the value of the attribute

@heapwolf
Copy link
Author

  • <tag foo="bar"> or <tag required foo="bar"> or </tag> or <tag src="foo"/> all match
  • but <tag required foo="/bar"> does not because of the slash inside the attribute value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment