Remove Numerical Value



  • 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



  • @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



  • @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.



  • 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



  • It works, Thanks alot Terry. Be blessed


Log in to reply