Edit : this answer referred to OP's first question, and it actually still answers is second :-p
Use boundaries, such as \b. \bwent\b
would match went.
Vincent Savard
2010-10-30 23:15:30
Edit : this answer referred to OP's first question, and it actually still answers is second :-p
Use boundaries, such as \b. \bwent\b
would match went.
This would match all capitalised words:
/\b([A-Z][a-z]+)\b/
Or just the word 'Dublin':
/\bDublin\b/
In some languages you can use () to specify a selection and then reference the first selection with $1 or 1.
This should match ever instance of Dublin in your sample, but you will have to look at the match groups because it would also capture the I in DublinIreland.
/(\bDublin)(\b|[A-Z])/g