Regex removes all numbers except those combined with alphabets

I am trying to remove numbers from this line, numbers that are not added with alphabetic characters

This is the line:

161072, OLD RECORIES HOLYWELL HILL ST ALBANS AL1 1BY,,      161408HOLYWELL HILL ST ALBANS AL1 1BT 162589,, PINETOP BIRKLANDS LANE ST ALBANS AL1 1EE

I want to delete 161072, 161408and 162589. I want this output:

OLD ADVERTISEMENT HOLYWELL HILL ST ALBANS AL1 1BY, HOLYWELL HILL ST ALBANS AL1 1BT, PINETOP BIRKLANDS LANE ST ALBANS AL1 1EE

Delete: 161072

Do not remove '1s' from: AL1 1BT

If I use \\d, then all numbers are deleted:

myString= myString.replaceAll("\\d", "");
System.out.print(myString);

? , . , , .

, ( ) :

()

: 1

+4
2

RegEx

\b\d+\b

, _ .

:

myString = myString.replaceAll("\\b\\d+\\b", "");

- Regex

+5

:

\\b\\d+\\b
+2

Source: https://habr.com/ru/post/1628840/


All Articles