Results 1 to 3 of 3

Thread: Regex Help needed.

  1. #1

    Default Regex Help needed.

    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.
    Last edited by tsarma; 02/19/2019 at 10:39.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    326

    Default

    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)
    Consulenza Contao CMS https://www.intco.it

  3. #3

    Default

    Thank you very much, yours solution seems working. I've here a test link

    https://regex101.com/r/hb02dk/1
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •