resolves the e-mail address in the text and URL
(1) , usage scenarios
parsing the required text from a given file is a common task in text processing. such as e-mail addresses,URLs , etc. can be found with appropriate regular expressions. We often need to parse and extract e-mail addresses from an e-mail customer list or HTML page that contains a large number of unrelated characters and words .
(2) , regular match
The regular expression that matches an e-mail address is as follows:
[A-za-z0-9._] [Email protected] [A-za-z0-9.] +\. [A-za-z] {2,4}
Match HTTP URL the regular expression is as follows:
Http://[a-za-z0-9\-\.] +\. [A-za-z] {2,4}
(3) , Example
Example 1 : Match Email
[Email protected]_01t]# cat A5.txt
This is aline of text contains,<email> #[email protected] </email> Andemail address,
Blog "http://www.google.com", [email protected] DFDFDFDDDFDF; [Email protected]<br/>
<ahref= "Http://code.google.com" >
[Email protected]_01t]# cat a5.txt |grep-e-O "[A-za-z0-9._][email protected][a-za-z0-9.] +\. [A-za-z] {2,4} "
[Email protected]
[Email protected]
[Email protected]
[[Email protected]_01t]#
Example 2 : Match URL
[Email protected]_01t]# cat A5.txt
This is aline of text contains,<email> #[email protected] </email> Andemail address,
Blog "http://www.google.com", [email protected]; [Email protected]<br/>
<ahref= "Http://code.google.com" >
[Email protected]_01t]# cat a5.txt |grep-e-O "http://[a-za-z0-9\-\.] +\. [A-za-z] {2,4} "
http://www.google.com
Http://code.google.com
[[Email protected]_01t]#
This article is from the "operation and maintenance of micro-letter" blog, please be sure to keep this source http://weixiaoxin.blog.51cto.com/13270051/1963698
Linux Shell Programming---Parsing email addresses and URLs in text