Community
    • Login

    Remove Numerical Value

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 717 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.
    • Gavin CampbellG
      Gavin Campbell
      last edited by

      I want to use regex expression with Notepad++ to delete any number which is directly next to a character like this:

      2Try
      3Look
      4Contact

      I want it to look like this:

      Try
      Look
      Contact

      1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by

        @Gavin-Campbell said in Remove Numerical Value:

        delete any number which is directly next to a character

        Using the Replace function we have
        Find What:\d+(\w)
        Replace With:\1
        As this is a regex we need search mode as regular expression

        Given the small amount you have provided this works. However there may be other instances where you don’t want it to work, such as when you have what123Test for example. If so you need to provide better explanation of the circumstances to edit and where to NOT edit.

        Terry

        1 Reply Last reply Reply Quote 1
        • Gavin CampbellG
          Gavin Campbell
          last edited by

          @Terry-R said in Remove Numerical Value:

          \1

          OK thanks. It does work with these:

          2Try
          3Look
          4Contact

          However it also finds numbers in the article like:

          32.2 degrees
          38 and 39 degrees

          and it changes them to

          2.2 degrees
          8 and 9 degrees

          So, how can i use a regex which only affects numbers which are directly next to a text value only rather numbers next to a numerial value.

          1 Reply Last reply Reply Quote 0
          • Terry RT
            Terry R
            last edited by Terry R

            Actually sorry, I did put you slightly wrong as \w refers to a longer list of characters rather than JUST a-z.

            Try
            Find What:(?i)\d+([a-z])
            Replace With:\1

            The `(?i) allows it to work with both upper and lower case a-z characters.
            Also note this will pick up multi digit numbers preceding a character.

            Terry

            1 Reply Last reply Reply Quote 2
            • Gavin CampbellG
              Gavin Campbell
              last edited by

              It works, Thanks alot Terry. Be blessed

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