REGEX code help


 
Thread Tools Search this Thread
Top Forums Programming REGEX code help
# 1  
Old 05-12-2010
REGEX code help

Hi,

I need as regex code for the following line:
Code:
May-12-10 13:16:41 82.249.21.94 <apoxidikyt3339@proxad.net> user unknown terry@somedomain.com;

The above line is a log from ASSP

A similar regex is mentioned in ASSP - Fail2ban, which is using log with a different pattern ( notice :[SMTP Error] 550 5.1.1 , this is not in the log above)

Please advise.

Thanks

Last edited by Yogesh Sawant; 05-26-2010 at 06:42 AM.. Reason: added code tags
# 2  
Old 05-12-2010
Quote:
Originally Posted by fed.linuxgossip
Hi,

I need as regex code for the following line:

May-12-10 13:16:41 82.249.21.94 <apoxidikyt3339@proxad.net> user unknown terry@somedomain.com;

The above line is a log from ASSP




A similar regex is mentioned in ASSP - Fail2ban, which is using log with a different pattern ( notice :[SMTP Error] 550 5.1.1 , this is not in the log above)




Please advise.


Thanks
Sorry... I don't understand. What is the question?
# 3  
Old 05-12-2010
Hi,

In ASSP - Fail2ban ,

Regex code for the log:
Code:
 Nov-14-09 00:14:50 54090-05322 201.244.255.72 <badguy@gtgwhhrthrth.com> [SMTP Error] 550 5.1.1 User unknown: your.user@your-domain.com

is
Code:
.*? \d{5}-\d{5} <HOST> <.*?> \[SMTP Error\] (.*)

I want help on setting up regex code for the log:

Code:
May-12-10 13:16:41 82.249.21.94 <apoxidikyt3339@proxad.net> user unknown terry@somedomain.com;


Last edited by Yogesh Sawant; 05-26-2010 at 06:43 AM.. Reason: added code tags
# 4  
Old 05-12-2010
Not really sure, if this is what you're after:
Code:
^[A-Z][a-z][a-z]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9]\?[0-9]\?.[0-9][0-9]\?[0-9]\?.[0-9][0-9]\?[0-9]\?.[0-9][0-9]\?[0-9]\? <.*> user unknown.*\?

Date+Time IP Stuff between < and > user unknown Stuff after user unknown (Optional)

I tried it like this:
Code:
grep -o "regexfromabovehere" filename

# 5  
Old 05-12-2010
Replace the sample's <HOST> string with the IP address for your host value (or is this the remote IP...?). Otherwise, it's pretty straightforward and lean provided it works...I'm often limited to approaches like pseudocoder's attempt since my system isn't quite the best regex env.
# 6  
Old 05-14-2010
thanks for giving it a shot, but it did not work as expected.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Regex

I dabbled with regex a few years back and failed miserably. I am trying to do two things, and dont know where to start. Heres my examples 1) Code Code CODERS should be Code Code Coders 2) Code Code CODERSFunny should be (3 Replies)
Discussion started by: jeffs42885
3 Replies

2. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

3. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

4. Shell Programming and Scripting

Help with REGEX??

i have a file 1.txt. the file contains: * server1.com : ewf,wefwef,wef,wef ------------------------------------- * server2.com : ewf,wefwef,wef,wef ------------------------------------- * server3.com : ewf,wefwef,wef,wef ------------------------------------- how can i read * ? from the... (2 Replies)
Discussion started by: zigizag
2 Replies

5. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

6. Shell Programming and Scripting

regex in ls

Hi Experts, I am using ls with regex in the below manner: VAR="*.txt *.TXT" ls -l $VAR This is working fine if I have both txt and TXT extension files in my directory. But if any of them is not present, its throwing errors, that *.TXT file not found in the directory. So what am i missing... (6 Replies)
Discussion started by: sugarcane
6 Replies

7. 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

8. Shell Programming and Scripting

regex help

I would like to search strings composed by only one type of charachter for example only strings composed by the charachter 'b' is it right? $egrep '\<(b+)+\>' filename Could be there some side effects? Regards. (1 Reply)
Discussion started by: and77
1 Replies

9. Shell Programming and Scripting

Regex

How do I write a regular expression to capture the comments of Pascal which are usually delimted by (* and *) or { and }? And also I need a regular expression to express financial quantities in American Notation. They have a leading dollar sign and an optional string of asteriks,a string of decimal... (1 Reply)
Discussion started by: saikrishnan7
1 Replies

10. Shell Programming and Scripting

Need a regex

Hi, I am trying to grep for the following type of string from a document given below: 12637 1239 3356 12956 7004 7004 7004 13381 13381 *> 12.0.1.63 0 7018 21872 ? * 208.51.134.254 53 0 3549 7018 21872 ?... (1 Reply)
Discussion started by: Legend986
1 Replies
Login or Register to Ask a Question