How can I select every a in a text, but not adjacent a's appearing before it. For example all bold a from the string below
a bcda bbba bxyaaa aaa abbb baaaabazsrbbaba baaaa
With this regex /[a]+/g, it select all occurrence of 'a'
Thank you.
Printable View
How can I select every a in a text, but not adjacent a's appearing before it. For example all bold a from the string below
a bcda bbba bxyaaa aaa abbb baaaabazsrbbaba baaaa
With this regex /[a]+/g, it select all occurrence of 'a'
Thank you.
try this:
/(a{1})(?!\1)/g
explanation:
(a{1}) exactly a single "a"
(?!\1) which isn't followed by the exact same match (\1 reference to the first match)
Thank you very much, yours solution seems working. I've here a test link
https://regex101.com/r/hb02dk/1