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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 stringKeep in mind it is a relatively easy task, and you can solve it with simple string manipulation.