Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
/
/
g
Input 1
1
New
phone_nums = c( "(123) 456-7890", "(123)456-7890", "1234567890", "123 456 7890", "123-456-7890", "123.456.7890") not_phone_nums = c("123.456 7890", "123-456.7890", "(123 456 7890", "a23.b123.c1234", "cleveland rocks" ) stopifnot(all(str_detect(phone_nums, re5))) stopifnot(! any(str_detect(not_phone_nums, re5)))
Extraction