Hi all, I'd like a regular expression for Java that can take this string
+1 7183541169 (East coast)
And produce two groups
- +1 7183541169
- East coast
I'm having difficulty with escaping the round brackets.
Hi all, I'd like a regular expression for Java that can take this string
+1 7183541169 (East coast)
And produce two groups
I'm having difficulty with escaping the round brackets.
Should be:
^(.*)\((.*)\)$
This assumes no special format - it will accept digits or letters anywhere. The regex reads:
^ - Start of the string
(.*) - some letters (captured group)
\( - literal (
(.*) - more letters (captured group)
\) - literal )
$ - end of string
Keep in mind it is a relatively easy task, and you can solve it with simple string manipulation.
/^(\+\d{1} \d+) \(((?:\w| |-)+)\)$/i
i don't know the rules for your string, but this should work.