Reputation: 159
I would like to construct regex (in JavaScript) that would return:
Is that possible?
Upvotes: 0
Views: 358
Reputation: 33908
Could be done with:
/(?=(test))(test-a)?/
Replace test
and a
with the pattern you are really looking for.
You may also want to anchor it, eg:
/^(?=(test))(?=(test-a)?)test(?:-a)?$/
Upvotes: 2