Very simple regex..

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
matt

Very simple regex..

Post by matt »

Hi all!

I hope you don't mnid me asking a simple question - I am trying to match 3 words on a line in an IIS log file.. They can appear anywhere on the line, but always in the same order!

Can anyone please help me in creating a reg ex in order to see these lines?

thanks in advance,
Matt
Stephan

Re: Very simple regex..

Post by Stephan »

Hi Matt,

something like

^\(.*word1.*word2.*word3.*\)$

should do, but this

word1.*word2.*word3

might be more performant...

A brief explanation:

^
Matches the beginning of a line

\( \) pair

a pair of parentheses will capture whatever was matched
inside for further reference (here the reference is '\1')
eg in a replace process.

.*
matches everything, except perhaps a new line...

word1
well, you 1st word

.*
matches whatever is there (that is anything between your
1st and 2nd word.

word2
you 2nd word to match

etc.

$
Matched the end of the line


Mind that .* _may_ macht nothing and _will_ match the whole rest of the line as a 1st try, and giving up a char at a time if the rest of the regex isn't able to math. Therefore using several .* is kind of potentially' dangerous' in terms of performance.


Hope that helped...

Stephan
Stephan

Re: Very simple regex..

Post by Stephan »

Hmmm, trying to neatly format a posting using spaces at the beginning of a line doesn't seem to work.

Sorry Matt - no formatting at this time!

Stephan
matt

Re: Very simple regex..

Post by matt »

thanks very much Stephan!

Now onto more complicated ones :)

thanks again
Matt
Carlyle Sutphen

Re: Very simple regex..

Post by Carlyle Sutphen »

<style type="text/css">
p {text-indent: 1cm}
</style>
<p>
Now, this might not work but I already tried setting italics and underline and <u>that</u> worked.
</p>
<p>
So let's see if css is allowed in this forum as well.
<center><big><big><big>;-)</big></big></big></p>
Carlyle Sutphen

Re: Very simple regex..

Post by Carlyle Sutphen »

Hmmm, nope, not all tags are supported.

Good thing, too! I forgot to turn off my center tag!
Post Reply