2
단일 정규식 줄 사용 (응용 프로그램의 구성 파일에 있음) 전자 메일 주소의 localpart를 캡처해야합니다.문자열을 PCRE에서 크기를 줄입니다
숫자로만 구성된 경우 수정되지 않은 채로 전달하십시오. 숫자가 아닌 문자가 있으면 최대 11자를 잘라냅니다.
이 간단한 프로그램을 테스트했지만 localpart가 11자를 넘으면 일치하는 것이 없습니다 (전자 메일 주소 전체가 인쇄 됨).
#!/usr/bin/env perl
my @emails = ('[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]');
for my $email (@emails){
# will put $1$2 on the substituion spot
$email =~ s/^(\d+)@.+|^([a-zA-Z0-9._%+-]{1,11})@.+/ /;
print '===> ' . $email . " \n\n ";
}
나는 어디로 가고 있습니까?
누군가가 그것을 보여주고 난 후에 분명 ... :) 감사! –