Sponsored Content
Top Forums Shell Programming and Scripting SED With Regex to extract Email Address Post 302618965 by CarloM on Wednesday 4th of April 2012 04:13:32 PM
Old 04-04-2012
Search 'RFC2822 regex' - the regular expression for the official standard for addresses is, um, long Smilie.
Code:
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|”(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*”)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

This User Gave Thanks to CarloM For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

2. UNIX for Advanced & Expert Users

Regex to match IP address

What do you think of this regex to match IP address? I have been reading up on regex and have seen some really long ones for IP. Would this fail in any scenarios? (+\.){3}* (5 Replies)
Discussion started by: glev2005
5 Replies

3. Shell Programming and Scripting

Using SED command in a shell script: Unterminated address regex

Hi All, I am trying to use a sed command in a shell script in order to delete some lines in a file and I got the following error message. I don't understand why it is not working 'cause I have tried with simple quotes, then with double-quotes, and it is not working. sed: -e expression #1,... (7 Replies)
Discussion started by: Alpha3363
7 Replies

4. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

5. Shell Programming and Scripting

Regex: Extract substring between 2 separator

Hi Input: aa-bb-cc-dd.ee.ff.gg Output: dd I want to get the word after the last '-' until the first dot I have tried with regex lookbehind and lookahead like this: (?<=-).*(?=\.) but his returns too much bb-cc-dd.ee.ff (7 Replies)
Discussion started by: chitech
7 Replies

6. Solaris

Find and sed for an email address in Solaris 10

in Solaris 10 I am able to run: find . -type f -name "copy*" exec grep example.com {} \; and I get results. but when I try to find and sed: find . -type f -name "copy*" exec sed -e 's/user@example\.com/user2@example\.com' {} \; the command executes correctly but doesn't change... (6 Replies)
Discussion started by: os2mac
6 Replies

7. Forum Support Area for Unregistered Users & Account Problems

Cant use certain email address

I tried to re-register using my new email address which is <firstname>@<surname>.me But it never sent out the email confirmation. I had to hit the back button and use my gmail address instead and it came through instantly. Is there a problem with using .me addresses? (1 Reply)
Discussion started by: frustin
1 Replies

8. Shell Programming and Scripting

Sed: -e expression #1, char 16: unterminated address regex

I am trying to grep for a particular text (Do action on cell BL330) in a text file(sample.gz) which is searched in the content filtered by date+timestamp (2016-09-14 01:09:56,796 to 2016-09-15 04:10:29,719) on a remote machine and finally write the output into a output file on a local machine. ... (23 Replies)
Discussion started by: rbadveti
23 Replies

9. UNIX for Beginners Questions & Answers

Sed: -e expression #1, char 20: unterminated address regex

I am trying to add word in last of particular line. the same command syntex is running on prompt. but in bash script give error."sed: -e expression #1, char 20: unterminated address regex" Please help. for i in `cat servername`; do ssh -q -t root@$i sed -i '/simple_allow_groups =/s/$/,... (4 Replies)
Discussion started by: yash_message
4 Replies
NE_IADDR_MAKE(3)						neon API reference						  NE_IADDR_MAKE(3)

NAME
ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_free - functions to manipulate and compare network addresses SYNOPSIS
#include <ne_socket.h> typedef enum { ne_iaddr_ipv4 = 0, ne_iaddr_ipv6 } ne_iaddr_type; ne_inet_addr *ne_iaddr_make (ne_iaddr_type type, const unsigned char *raw); int ne_iaddr_cmp (const ne_inet_addr *ia1, const ne_inet_addr *ia2); char *ne_iaddr_print (const ne_inet_addr *ia, char *buffer, size_t bufsiz); ne_iaddr_type ne_iaddr_typeof (const ne_inet_addr *ia); void ne_iaddr_free (const ne_inet_addr *ia); DESCRIPTION
ne_iaddr_make creates an ne_inet_addr object from a raw binary network address; for instance the four bytes 0x7f 0x00 0x00 0x01 represent the IPv4 address 127.0.0.1. The object returned is suitable for passing to ne_sock_connect. A binary IPv4 address contains four bytes; a binary IPv6 address contains sixteen bytes; addresses passed must be in network byte order. ne_iaddr_cmp can be used to compare two network addresses; returning zero only if they are identical. The addresses need not be of the same address type; if the addresses are not of the same type, the return value is guaranteed to be non-zero. ne_iaddr_print can be used to print the human-readable string representation of a network address into a buffer, for instance the string "127.0.0.1". ne_iaddr_typeof returns the type of the given network address. ne_iaddr_free releases the memory associated with a network address object. RETURN VALUE
ne_iaddr_make returns NULL if the address type passed is not supported (for instance on a platform which does not support IPv6). ne_iaddr_print returns the buffer pointer, and never NULL. EXAMPLES
The following example connects a socket to port 80 at the address 127.0.0.1. unsigned char addr[] = "x7fx00x00x01"; ne_inet_addr *ia; ia = ne_iaddr_make(ne_iaddr_ipv4, addr); if (ia != NULL) { ne_socket *sock = ne_sock_connect(ia, 80); ne_iaddr_free(ia); /* ... */ } else { /* ... */ } SEE ALSO
ne_addr_resolve(3) AUTHOR
Joe Orton <neon@webdav.org>. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWneon | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for Neon is available on http://opensolaris.org. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWneon | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for Neon is available on http://opensolaris.org. neon 0.25.5 20 January 2006 NE_IADDR_MAKE(3)
All times are GMT -4. The time now is 11:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy