...

View Full Version : Regular Expression



A1ien51
03-19-2004, 04:42 AM
I am splitting a string by commas

pattern = /, /

,space

now that gets me around the dollar sign...

$239,950, 2111, Ganton Green, No. 212, 2, 2/0, Colonial 9/29 /2003, 21163, HOWARD CO.

but I also want to ignore the part in bold

right now it is splitting it as

$239,950
2111
Ganton Green
No. 212
2
2/0
Colonial
9/29
2003
21163
HOWARD CO.

but I want it to be like

$239,950
2111
Ganton Green, No. 212
2
2/0
Colonial
9/29
2003
21163
HOWARD CO.

I been playing around with it, but can not get it to work...

Thanks
Eric

glenngv
03-19-2004, 05:05 AM
Why not use a different separator that would not come up in the data? Like, say, a pipe

$239,950|2111|Ganton Green, No. 212|2|2/0|Colonial 9/29 /2003|21163|HOWARD CO.

or better, use \n

joh6nn
03-19-2004, 05:23 AM
if he hasn't got control over the input format, then that won't work. since he's not doing it that way, i'm gonna guess that he hasn't got any control over it. ; )

using /, (?!No\.)/ as your separator pattern should do it, but that assumes that No. will consistantly follow that comma.

A1ien51
03-19-2004, 01:54 PM
I have no control this information come from a text file that is generated by another service. The file is a bunch of junk with no formatting. I got it all the way down to this and thanks to joh6nn it works.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum