RegEx help

This topic is: resolved

 

Thank you for contacting me. Please note that I live in the GMT+3 time zone - responses might be delayed by this.

This topic has 7 replies, 2 voices, and was last updated 2 years, 8 months ago by Szabi – CodeRevolution.

Viewing 7 reply threads
  • Author
    Posts
    • #4865


      daniel-dani
      Participant
      Post count: 9

      Hi there,

      I am trying to configure regex which will remove numbers in brackets (including brackets).

      Something like:

      (4)

      (123)

      (1, 23)

      I tried this regex: ((\d))

      And it’s removing numbers but in brackets but not brackets itself.

      Can you please help?

      Daniel

    • #4866


      Szabi – CodeRevolution
      Keymaster
      Post count: 4621

      Hello,

      First of all, thank you for your purchase.

      Brackets need to be escaped with slashes, as they are Regex operators. So, I suggest you try using:

      (\(\d*\))

      Also, to match (1, 23), I suggest:

      (\([\d\s,]*\))

      You can write your Regex expressions with more ease, on this site, where you can also see their matches: https://regexr.com/

      Let me know if this helped.

      Regards, Szabi – CodeRevolution.

    • #4888


      daniel-dani
      Participant
      Post count: 9

      yep, thanks for your help but for some reason it does not work. Am I doing this right? Please see attached screen.

      Attachments:
      You must be logged in to view attached files.
    • #4890


      Szabi – CodeRevolution
      Keymaster
      Post count: 4621

      Hello,

      Interesting, because the Regex seems to be correct.

      Can you send me, please, temporary admin login credentials to your WordPress install, so I can check this issue out? Send it, please, to my email address: kisded@yahoo.com

      Regards, Szabi – CodeRevolution.

    • #4908


      daniel-dani
      Participant
      Post count: 9

      Hi Szabi,

      I just send you Admin credentials on your email.

      Dan

    • #4909


      Szabi – CodeRevolution
      Keymaster
      Post count: 4621
      Hello,
      I checked and the source article was scraping also some invisible HTML tags in the numbers, example:
      (<hl-trusted-source source=”PubMed Central” rationale=”Highly respected database from the National Institutes of Health”>1</hl-trusted-source>)
      To match also these extended HTML tags I modified the Regex as follows:
      (\((?:<hl-trusted-source[\s\S]*?)?[\d\s,]*(?:<\hl-trusted-source>)?\))
      I applied it to rule ID 0 on your site, please check results.
    • #4955


      daniel-dani
      Participant
      Post count: 9

      Hi Szabi,

      Look like it works! Thanks a lot!

      Daniel

    • #4957


      Szabi – CodeRevolution
      Keymaster
      Post count: 4621

      I am glad to hear this!

      If you enjoy using the plugin, please give it a rating on CodeCanyon, it is really appreciated!

      Regards.

Viewing 7 reply threads

The topic ‘RegEx help’ is closed to new replies.