Regular expressions

agnitrate

Diamond Member
Jul 2, 2001
3,761
1
0
I'm having a hard time trying to figure out a regular expression to match several things in a text file. I'm trying to search for different elements inside the text file and match them all within the same query, but I just can't seem to do it right.

Example file:

"From test@123.com

Here is the rest of the stuff for the file

Resolved by: username at: 12/08/05 11:38:54

Stuff on bottom here"

I'd like to be able to search for 'From xxx@xxx.com' and 'Resolved by: username' individually or in conjunction. This regular expression did not match:

Example regex:
(From xxx@xxx.com)(.|\n)*(Resolved by: username)

I am not sure how to regard the white space in the middle of the file. Does anybody have some insight into making this regex fit? I can use all the help I can get :)

Thanks.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
This doesn't work?
(From xxx@xxx.com)|(Resolved by: yyyyyyyy)

IF those are the only two lines you're cocerned about, and you're only interested in those two lines and not the intermediate text, that seems fine.
 

agnitrate

Diamond Member
Jul 2, 2001
3,761
1
0
Originally posted by: notfred
This doesn't work?
(From xxx@xxx.com)|(Resolved by: yyyyyyyy)

IF those are the only two lines you're cocerned about, and you're only interested in those two lines and not the intermediate text, that seems fine.

Yes, that does match for my specific file. However, won't that regular expression also match any that has either (From xxx) or (Resolved by: xxx) individually as well? I'd like to make it an (A && B) type of expression as opposed to an (A || B).

This is a step in the right direction for me though. I'm going to try and play with it some more.