I have a regular expression: \d+|[a-z]+
. What this does is, if you have 81a, it splits into 81 and a. I have tested it on Regex101 and it works fine. I use it in my JavaScript code using match and works fine there too.
The problem is I need use this in my apex class, but unfortunately it doesn't work. I used both
String numberAddress = '818a';
Boolean test = Pattern.matches('/\\d+|[a-z]+/ig', numberAddress);
List<String> splitted = numberAddress.split('/\\d+|[a-z]+/ig');
On doing system debug I get test
as false
and splitted
as a list with one element 818a
and not (818, a)
.
Any ideas how to make it work?