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
我不知道你的字符串的规则,但这应该工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.