Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Regex replacement not working

    Help wanted · · · – – – · · ·
    2
    2
    52
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Paul Moloney
      Paul Moloney last edited by

      I’ve checked the following regex string against a number of regex syntax checkers and it’s valid:

      <img src="([A-Za-z0-9-_\.%]*)" alt="([A-Za-z0-9-_\.]*)"(\s)*\/>
      

      regex_test.PNG

      (I’ve also tried the alternative where the double-quotes are escaped:

      <img src=\"([A-Za-z0-9-_\.%]*)\" alt=\"([A-Za-z0-9-_\.]*)\"(\s)*\/>
      

      However, neither of these work for me in Notepad++ regex:

      regex_dialog.PNG

      Any help on the valid syntax for Notepad++ appreciated (what flavour of regex does it use?

      P.

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @Paul Moloney last edited by

        @Paul-Moloney said in Regex replacement not working:

        Any help on the valid syntax for Notepad++ appreciated (what flavour of regex does it use?

        The docs explain Notepad++ uses the Boost regular expression library (v1.70).

        But in every regex version I’ve used, [A-Za-z0-9-_\.%] would cause problems; in general, hyphens mean “range” inside a character class, unless they are escaped or the last character in the class. So [0-9-] is okay, [0-9-_] is not, but [0-9_-] is (non-range hyphen last) and [0-9\-_] is.

        1 Reply Last reply Reply Quote 3
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors