I have a string like “AAA 101 B202 C 303 ” and I want to get rid of the space between char and number if there is any.
So after operation, the string should be like “AAA101 B202 C303 “. But I am not sure whether regex could do this?
Any help? Thanks in advance.
Yes, you can do this with regular expressions. Here’s a short but complete example:
(If you’re going to do this a lot, you may well want to compile a regular expression for the pattern.)
The
\p{L}matches any unicode letter – you may want to be more restrictive.