Community
    • Login

    Regex replacement not working

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 722 Views 2 Watching
    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 MoloneyP Offline
      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.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors