Community
    • Login

    Put 2 single quotation marks around a number

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 2.0k Views
    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.
    • Doug TatomD
      Doug Tatom
      last edited by Doug Tatom

      I have text files that have numbers 1 2 3 etc. I would like to do a find/replace that find the numbers then puts 2 single quotation around that number. Is this possible to do in Notepad++. Or, is there a better simpler solution to do this?

      Thanks for any help!!!

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by PeterJones

        @Doug-Tatom

        The naive interpretation of what you stated:

        • FIND = \d+
          find one or more digit characters in a row
        • REPLACE = '$0'
          replace it with a single quote, the contents of the match, and a single quote
        • SEARCH MODE = regular expression

        Unfortunately, with how little you told us, I was not able to protect that expression against edge cases. If you give us better examples (see the italics below), you will get better answers

        ----

        Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual Markdown syntax. To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors