Reputation: 319
I would like to strip specific character (the ampersand) match from any position on a string. An example of strings are;
&Discounts
Dis&counts
Discounts&
& Discounts
Discounts &
&
I use the regex &(?=\s|[a-zA-Z1-9])
but it can only match the ampersand at the beginning and the middle of the string. How can I also match if the ampersand is at the end of the string. And should be able to exclude match &
. Modified my regex to &(?=\s|[^amp;])
. It was able to exclude the string &
but still not able to match the ampersand at the end of the string.
Upvotes: 2
Views: 474