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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -