Java String regex replace
My string structure is following
characters 1-3 are uppercase alphabets including diacritics such Ň Ö Ï
Characters 4-7 will always be numbers.
8th is space
9th is forward slash
10th space
11th onwards are number.
String str1 = "DIW7850 / 42";
String str2 = "QLR3571 / 11";
String str3 = "UÜÈ7477 / 00";
String str4 = "A / P8538 / 28";
String str5 = "CV0875Z / 01";
String str6 = "SW / 2188 / 38";
I wanted replace first 3 characters such as
replaceAll("[2]", "Z")
.replaceAll("[0]", "O")
.replaceAll("[5]", "S")
.replaceAll(" // ","Ï) // replace space forward_slash space with Ï
and position where numbers with following
.replaceAll("(?i)L|(?i)I", "1")
.replaceAll("(?i)o", "0")
.replaceAll("(?i)s", "5")
.replaceAll("(?i)z", "2")
AGdev
- 616
- 8
- 12
lang-java