I wrote a regular expression to omit characters after the first occurrence of some characters (and #)
String number = "(123) (456) (7890)#123";
number = number.replaceAll("[,#](.*)", ""); //This is the 1st regex
Then the second regular expression receives only numbers (removes spaces and other non-digital characters)
number = number.replaceAll("[^0-9]+", "");
Output: 1234567890
How can I combine two regular expressions into one, for example, from O / p from the first regular expression to the second.
source
share