Reputation: 1238
I'm trying to build my regular expression, but I've failed. I'm trying to get everything after single or double dash (you can try it here):
var regEx = /(?<=[-{1,2}])[^-]\S*/g;
It works just fine, but it selects even if we have 3+ dashes too. I've tried something like /(?<=^[-{1,2}])[^-]\S*/g
and /(?<=\b[-{1,2}])[^-]\S*/g
, but then it crashes at all.
Thanks in advance.
Upvotes: 2
Views: 72
Reputation: 32787
Unfortunately javascript
doesn't support lookbehind
You can use this regex with multiline
option
^-{1,2}(?!-)(\S*)
After this you can use group 1 to access the required match..
Upvotes: 1