Help to write a regular book that will ONLY leave numbers in a line.

    2 answers 2

    Thank you @vv2cc for comments.

    The best option:

    someString.replaceAll("[^\\d]",""); 

    Replaces all symbols except digits with a blank symbol.

    • one
      . / * $ ....? - vv2cc
    • These characters will leave. Left at the discretion of the author. It is not known exactly which characters will appear in the source text. - pkamozin 1:09
    • one
      so in the condition of the task - it is necessary ONLY the numbers =) - Gorets
    • I agree, the method is not ideal. Indeed, it is better to go from the opposite - select only numbers and forget about the rest =) - pkamozin

    Regular expression that highlights everything except numbers: / \ D /