You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hunter Hillegas <li...@lastonepicked.com> on 2003/05/29 01:54:56 UTC

[OT] Regular Expression Help

This is off-topic but if someone could help, that would be great.

Please respond off list.

I need help with a regular expression. These are always hard for me.

I have several lines of input like this:

maillog-May 26 16:29:50 vader sendmail[22129]: h4QLTob22129:
from=<so...@hotmail.com>, size=967, class=0, nrcpts=1,
msgid=<La...@hotmail.com>, proto=ESMTP, daemon=MTA,
relay=f9.
law10.hotmail.com [64.4.15.9]

I want to extract just the from address (some_address@hotmail.com) and send
it to output, but I am having trouble getting it right. Any help is
appreciated.

Thanks,
Hunter


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [OT] Regular Expression Help

Posted by Mark Galbreath <ma...@qat.com>.
Yiddish?

-----Original Message-----
From: Xu Cheng [mailto:xucheng_chn@yahoo.com.sg] 
Sent: Thursday, May 29, 2003 8:51 AM

Concrete example will depends on your language.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] Regular Expression Help

Posted by Xu Cheng <xu...@yahoo.com.sg>.
you can define the pattern to be something like: 
form=<([^>]+)>
and then apply it to the string and get value of $1.
I can't remember if < and > are special characters. If they are, you can add \ 
in front to escape them. I don't have a reference with me so can't give you 
the exact answer.

Concrete example will depends on your language.

On Thursday 29 May 2003 07:54, Hunter Hillegas wrote:
> This is off-topic but if someone could help, that would be great.
>
> Please respond off list.
>
> I need help with a regular expression. These are always hard for me.
>
> I have several lines of input like this:
>
> maillog-May 26 16:29:50 vader sendmail[22129]: h4QLTob22129:
> from=<so...@hotmail.com>, size=967, class=0, nrcpts=1,
> msgid=<La...@hotmail.com>, proto=ESMTP, daemon=MTA,
> relay=f9.
> law10.hotmail.com [64.4.15.9]
>
> I want to extract just the from address (some_address@hotmail.com) and send
> it to output, but I am having trouble getting it right. Any help is
> appreciated.
>
> Thanks,
> Hunter
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [OT] Regular Expression Help

Posted by Mark Galbreath <ma...@qat.com>.
Oops...off in ASP land again.  The second array is not needed.

-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com] 
Sent: Thursday, May 29, 2003 9:57 AM
To: 'Struts Users Mailing List'
Subject: RE: [OT] Regular Expression Help


Regular expressions are valuable to Struts developers, too.  :-) Using J2SE
1.4, you could:

String[] temp_1 = new String[ 3 ];
temp_1 = line.split( "<" );
String[] temp_2 = new String[ 1 ];
String email = temp_1[ 1 ].split( ">" );

or

import java.util.regex.Pattern;
import java.util.regex.Matcher;

Patter p = Pattern.compile( "<[^>](.*)>" );
Matcher m = p.matcher( line );

if( m.group() != null ) {
  String email = m.group();
}

Mark

-----Original Message-----
From: Hunter Hillegas [mailto:lists@lastonepicked.com] 
Sent: Wednesday, May 28, 2003 7:55 PM

I have several lines of input like this:

maillog-May 26 16:29:50 vader sendmail[22129]: h4QLTob22129:
from=<so...@hotmail.com>, size=967, class=0, nrcpts=1,
msgid=<La...@hotmail.com>, proto=ESMTP, daemon=MTA,
relay=f9. law10.hotmail.com [64.4.15.9]

I want to extract just the from address (some_address@hotmail.com) and send
it to output....



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [OT] Regular Expression Help

Posted by Mark Galbreath <ma...@qat.com>.
Regular expressions are valuable to Struts developers, too.  :-) Using J2SE
1.4, you could:

String[] temp_1 = new String[ 3 ];
temp_1 = line.split( "<" );
String[] temp_2 = new String[ 1 ];
String email = temp_1[ 1 ].split( ">" );

or

import java.util.regex.Pattern;
import java.util.regex.Matcher;

Patter p = Pattern.compile( "<[^>](.*)>" );
Matcher m = p.matcher( line );

if( m.group() != null ) {
  String email = m.group();
}

Mark

-----Original Message-----
From: Hunter Hillegas [mailto:lists@lastonepicked.com] 
Sent: Wednesday, May 28, 2003 7:55 PM

I have several lines of input like this:

maillog-May 26 16:29:50 vader sendmail[22129]: h4QLTob22129:
from=<so...@hotmail.com>, size=967, class=0, nrcpts=1,
msgid=<La...@hotmail.com>, proto=ESMTP, daemon=MTA,
relay=f9. law10.hotmail.com [64.4.15.9]

I want to extract just the from address (some_address@hotmail.com) and send
it to output....



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org