Javascript regex ending word not found -
in regex , need match ending word starts '(', ')' or ','.
regex :
/[\(\),].*$/ for example, given text (aaa,bbb)ccc need obtain )ccc. still, returns entire text. what's wrong regex?
you can use:
'(aaa,bbb)ccc'.match(/[(),][^(),]+$/) //=> [")ccc"] [^(),]+ negation pattern matches character listed in [^(),].
problem [(),].*$ matches first ( in input , matches till end.
Comments
Post a Comment