help with Regular Expression

General questions about using TextPad

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

Post Reply
skwareks
Posts: 15
Joined: Wed Mar 02, 2005 6:36 pm
Location: Toronto

help with Regular Expression

Post by skwareks »

I need a regular expression that will only match the Letter "E" which is the first character in line of first sting so:

E<email>

I need to find incorporate regular expression that will only look for the lines that start with an E. Any ideas? :-) Is it possible?
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

To match an E at the beginning of the line:

^E

Don't know what you mean with "first sting" in this context ...
skwareks
Posts: 15
Joined: Wed Mar 02, 2005 6:36 pm
Location: Toronto

Post by skwareks »

Yes, I tried that but then it looks into all strings in the given line. I need it to look at only the first letter of the first string.... :-( .. any ideas?
ben_josephs
Posts: 2457
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Please give complete examples of the lines that you are searching and describe precisely what in these lines you want to match. Please put your text examples in a "code" block, like this:

Code: Select all

    to preserve the layout
skwareks
Posts: 15
Joined: Wed Mar 02, 2005 6:36 pm
Location: Toronto

Post by skwareks »

Ok. Here is the example of content of the file:

ESKWAERKS@YAHOO.COM
SPPPPPP ELECTRONIC TTTT TTTTTTTT
BDateDDDDDD /30/02
ESKWAERK2@YAHOO.COM
SPPPPPP ELECTRONIC TTTT TTTTTTTT
BDateDDDDDD /30/02


Now I need to divide the file into mulitple files so it will become

File1
ESKWAERKS@YAHOO.COM
SPPPPPP ELECTRONIC TTTT TTTTTTTT
BDateDDDDDD /30/02

File2
ESKWAERK2@YAHOO.COM
SPPPPPP ELECTRONIC TTTT TTTTTTTT
BDateDDDDDD /30/02


I am using webMethods to do so and have a javaclass that will do it for me. The only thing that I need determine the delimiter in Regular Expression that will search for "E" as the first letter in the first string of the line. Hope its not to confusing. :-)
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Hmmm, I see a few problems you'll be having. The first is that you'd like to split the results out into a file per match and that is nothing a text editor is likely to do. The second is that you want to match the line that starts with E and the two lines after that. If it is always 3 lines that need matching, then
^E.*\n.*\n.*
will work to match. At this point, you'll still be stuck with how to split the file out. I suspect a quick script/program will be your best bet but if you are writing that, you might as well incorporate the regular expression into it.
I choose to fight with a sack of angry cats.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

In Textpad (you are here in a support forum for the text editor Textpad) ^ anchors the regex at the beginning of the line. Definitely.

If you are seeking support for some other regex engine here in the Textpad forum, the very least you should do is to specify that you are not talking about Textpad's regex engine, and which regex engine you do use.
Ok, you are using java - but still there are several regex engines implemented in Java (java.util.regex, gnu.regex, jakarta.regex, com.ibm.regex just to mention a few ...)
You should also mention how you are using your regex engine (flags in the calls might matter ...)
Post Reply