I'm trying to change all ":)" (without quotes) to pictures. To make a match, a smiley must be surrounded by spaces (or be at the beginning or the end of a string).
if a smiley is (at the beginning of a string or has a white-space before it) and (is at the end of a string or has a white-space after it);
How about the regex
Example : http://regex101.com/r/zY9xA3/2
:)is consumed by the regex engine that for the second
:)we cannot have a presceding
Use a positive look ahead so that the the space after is not consumed by the regex.
(?=\s|$)look ahead asserts that
:)is followed by space or end of string. But wont consume the character.
: you need not escape the the
(?:$|\s) non capturing group to positive look ahead