Reputation: 7191
regex for begin where find 'abc' end where first find 'xyz'.
I can write:- var regex = /abc/
to match the exact abc
.
I'm trying to read more. Any help is appreciated.
following tutorial
Upvotes: 0
Views: 182
Reputation: 785256
You can use this regex:
var regex = /\babc\b.*?\bxyz\b/;
\b
is for word boundaries to make it match abc
and xyz
specifically not aabc
or xyz123
Upvotes: 1
Reputation: 336198
The simplest way would be
/abc.*?xyz/
.*?
means "Match any number of characters, as few as possible.
Upvotes: 1