采用稍有不同的做法,对你们也是有益的...... 在获得电话号码信息之前,我先采用某种方法,包括提取所需信息并重新定位,但你可能有不符合这一解决办法的要求,但我要建议这样做。
Using this match expression:
(?i)^D*1?D*([2-9])D*(d)D*(d)D*(d)D*(d)D*(d)D*(d)D*(d)D*(d)D*(d)[^x]*?s*(?:(?:e?(x)(?:.|t.?|tension)?)D*(d+))?.*$
改为:
($1$2$3) $4$5$6-$7$8$9$10 $12$13
你们应当能够改革这些投入:
Input Output
----------------------------- --------------------------------
"1323-456-7890 540" "(323) 456-7890 "
"8648217634" "(864) 821-7634 "
"453453453322" "(453) 453-4533 "
"@404-327-4532" "(404) 327-4532 "
"172830923423456" "(728) 309-2342 "
"17283092342x3456" "(728) 309-2342 x3456"
"jh345gjk26k65g3245" "(345) 266-5324 "
"jh3g24235h2g3j5h3x245324" "(324) 235-2353 x245324"
"12345678925x14" "(234) 567-8925 x14"
"+1 (322)485-9321" "(322) 485-9321 "
"804.555.1234" "(804) 555-1234 "
我恳请你不要说最有效率的表述,但低效的格言不是。 a 案文篇幅较短的问题,特别是在有知识和少量照料的情况下。
打破 par语:
(?i)^D*1?D* # mode=ignore case; optional "1" in the beginning
([2-9])D*(d)D*(d)D* # three digits* with anything in between
(d)D*(d)D*(d)D* # three more digits with anything in between
(d)D*(d)D*(d)D*(d)[^x]*? # four more digits with anything in between
s* # optional whitespace
(?:(?:e?(x)(?:.|t.?|tension)?) # extension indicator (see below)
D*(d+))? # optional anything before a series of digits
.*$ # and anything else to the end of the string"
三位数不能从0或1位开始。 扩展指标可以是x
,ex
,xt
,ext
。 (所有时间可在末尾)extension
,或xtension
。 (期限不能结束)。
如书面所述,延期(数字,即)必须是一系列连续的编号(但通常都是,正如你所说的话)
The idea is to use the regex engine to pull out the first 10 digits (excluding "0" and "1", because domestic U.S. telephone numbers do not start with those (except as a switch, which is not needed or always needed, and is not dependent upon the destination phone, but the phone you re typing it into. It will then try to pull out anything up to an x , and capture the x , along with the first contiguous string of digits after that.
它允许在输入格式方面采取相当宽容的态度,同时排除有害数据或元数据,然后制作一个一贯设计的电话号码(一些电话经常受到许多层次的赞赏)。