Using this regex: (.*)(EB([s]{0,})[0-9]{7})
to remove white spaces and able to read 7 digits after EB
but its not accepting space between digits.
Currently it’s passing value with space after EB
and not accepting space in b/w 7 digits.
Input string: EB 67645 89
Using value.replaceAll("s","");
in code.
2
Answers
You can try this regex, it should help to solve your problem:
By the way you can use regex101 to play with regex, it’s very useful environment when you’re working with regexps.
To match the example string you don’t need the capture groups, you can match 7 times a digit preceded by optional whitespace chars (note that it can also match newlines).
Then you can remove the whitespace chars from this match using replaceAll:
In Java
Regex demo