이것은 US의 수치 작동은 :
^ # beginning of string, or BOL in multi-line mode
(?:[+]?1[-. ]){0,1} # optional calling code, not captured
\(? # optional common prefix for area code, not captured
([2-9][0-8][0-9])? # optional NANP-allowed area codes, captured in $1
[)-. ]* # optional common delimiters after area code, not captured
( # begin capture group $2 for exchange code
[2-9] # first digit cannot be a 1
(?:[02-9][0-9]|1[02-9])) # second and third digit cannot be "11"
) # end capture group for exchange
[-. ]? # common delimiters between exchange and SN, not captured
([0-9]{4}) # subscriber number, captured in $3
(?: # start non-capturing group for optional extension
\s*(?:x|ext|ext.)\s* # common prefixes before extension numbers
(\d+) # optional extension, captured in $4
){0,1} # end non-capturing group
$ # end of string, or EOL in multi-line mode
이 호출 코드 (선택적), 세미 유효 영역 코드 (선택적) 교환 코드 (선택적) 내선 번호를 처리하고, 각 부분을 캡처 전화 번호를 별도의 변수에 입력하여 손쉽게 추출하고 조작 할 수 있습니다.
.NET에서이 표현식을 사용하면 쉼표가 무시되고 ^
및 $
문자가 문자열의 모든 행에서 전화 번호를 찾을 수 있도록 IgnorePatternWhitespace 및 MultiLine 플래그를 포함해야합니다.
C#에는 정규식이 없습니다. –
@ 존 : 저는 C#에서 정규 표현식을 사용해야한다는 것을 의미했습니다. 그러나 일을 분명히 해주셔서 감사합니다. – effkay