Reputation: 2800
How do I change this regular expression:
(`)([^`]+)`|(\*)([^*]+)\*
To give an output like this:
` | hel*low
* | low`orld
* | hello
` | world
When passed:
"`hel*low`orld* *hello* `world`"
Upvotes: 0
Views: 87
Reputation: 89574
You can use this pattern:
(?=([`*])((?>[^`*\W]++|(?!\1)[`*])+)\1)
or this pattern:
(?=([`*])((?:[^`*\W]+|(?!\1)[`*])+)\1)
Upvotes: 2