Sunday 15 February 2015

Regex to match "&" only if preceded by a single word and space? -



Regex to match "&" only if preceded by a single word and space? -

i'm looking way match ampersand in look if preceded single word , space. (it should not match beyond ampersand unless it's preceded 1 word , space.) need match first surname @ origin of file name , begin letter a.

demo

paul & mary atkins - (match should be: paul & mary atkins) john arnold & dave badman - (match should be: john arnold) ----do not match---- john baines & dave adams -

for utilize in file renamer, flavor javascript.

this regex

/(^\w+ &.*)/

matches lines single word followed space , &. see demo.

note matches first line in example.

regex

No comments:

Post a Comment