Sublime Forum

Removing mask of numeric string (or replace keeping digits)


I’ve searched for a method to remove all non-digit chars from a selection.
I didn’t found a proper package.
I tried CTRL + H with the RegEx /[^0-9]+/ but it replaced literally. The RegEx was not interpreted. Example:
I have this selection

bbsc 22.999.333/1111-77

, used CTRL + H this way:

and the replace result was:


What am I missing? Thanks!



I believe the Find should be [^0-9] and Replace should be nothing (empty) and then a Replace All operation will simply remove any non digit characters.

1 Like


It worked fine!
Let´s say that my selection have multiple lines. In this case de command is removing de linebreaks too and joining all. Can we preserve the line breaks too? Thanks!



Yes, you just need to be more specific with the regex. Instead of [^0-9], it should be [^0-9\n] which excludes all numbers and new lines as well.

1 Like