Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use regexp to grab entire line

Status
Not open for further replies.

spiveygb

Programmer
Jun 24, 2003
27
0
0
US
I have a tab delimited file in the following format:
USGS 3453000 VY RIVER NEAR MARSHALL, NC 03 00065 2003-06-30 10:15:00 2.47 0 2003-06-30 10:21:12

I am trying to use RegExp to grab the information I need out of a text file. The unique field to search on is the second column (i.e., 3453000 (this will be substituted with a variable later)) to locate a match. However, I need to get the entire line of information. I have a couple of questions on how to do this. First, would it be better to search on just the second column and somehow read the entire line or develop a robust pattern that captures all of the data at once? Secondly, if the second option is the better way to go then could someone please help with the pattern? They are very daunting to say the least. Thanks!
 
RegExp is one of my favorite tools. However it is a real bear to master. With out knowing what language your coding in I will assume you understand arrays. Take the entire line in at once and convert to an array delim with tab or some ident char that consistently breaks yur line up into cols. VBScript:SPLIT() Javascript:eek:bj.split().

With RegExp you can search for a tab char using a word boundary. but without knowing how consistent your data is, writing conditional REGEXP can get scary.

-Logan5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top