Created
March 17, 2010 17:52
-
-
Save swalke16/335509 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Regex to match the following (JavaScript): | |
before | |
before {each:1,shared:1} | |
after | |
after {each:1,shared:1} | |
The patterns should match at the beginning of a line, and ends at the end of a line. The before/after part should be captured into backreference $1 and the {} part should be captured into backreference $2 (if it exists). | |
Here's what I've got so far, I think it's close, the only real problem I know of is that in the simple before/after case it's capturing the before/after into backreference $3 instead of $1. | |
^ *(before|after) *?({.+?})(?= |$)|(before|after)(?= |$) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment