我有一个大字符串,如下所示。 我想提取字符串中的3个数字 1.9886991201 2. + 7189674123 3.(080)-2235456
$var = '
rst post. Edit or delete it, then start writing!
will change the whole world
Search for:
Search …
RECENT POSTS
This is my first blog post
Hello world!
RECENT COMMENTS
Mr WordPress on Hello world!
ARCHIVES
August 2016
July 2016
CATEGORIES
Uncategorized
META
Log in
Entries RSS
Comments RSS
WordPress.org
Proudly powered by WordPress
dajsnjdgffffffffffffffffffffffffffffffffffz
9886991201...dfsdsddfgf
ddffgbnfhgjhjgjg
dfknfkjkndfdjkfdjjjjjjjjjjjjjjjj
mskjndkjdnndnjdfjjdm
njcddfdnfnzdfdzfdzfdj+7189674123msdfjgfdxfds
dwasnkbnznfvnndfv
aefnbhjmbffdsnfnndv
dmlnjdnvdnsnvdndv
dLKMNJFNNFVNFGN
DNBFDBFJFDJF
do code...
while (fsdkmnbv vx b s
fgzd zvn bmbfmbfxmbfxm);,dwdfen (080)-2235456 ananczzzzzzzzzz bcxxx AS SNDMCKJASOL P0-`0-1`1WE2IQ82EYQWASHBZXNdwhbjbjdhhhhhhhhhhhhhhhhhas
dmfndsvfncx
';
答案 0 :(得分:2)
根据您的描述,我会看到您要搜索的三种不同的数字模式。
+
后跟10位数字可以使用以下正则表达式匹配此模式
/[\+]?\d{10}|\(\d{3}\)\s?-\d{6}/
https://regex101.com/r/dJ9cV2/5