[Solved] Javascript Regex Conditional

[ad_1]

Here’s a solution which uses non-capturing groups (?:stuff) which I prefer so I don’t have to dig through the result groups to find the string I’m interested in.

(?:#)(?:[\w\d]+-)?([\w\d]+)

First it throws out the # character, then throws out the stuff up to and including the - character, if it is there, then groups the rest as your match.

5

[ad_2]

solved Javascript Regex Conditional