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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding, then extracting text string of a particular format

Status
Not open for further replies.

addy

Technical User
May 18, 2001
743
0
0
GB
Hi

I have a large approx. 400,000 records which have a text field of up to 250 characters in length. I would like to search for a text string of a particular format, for example, LLL-NNNNN where L is any letter and N is any number and if found, I would like to extract the particular string from the text.

Searching for all records which contain a text string which contains this format isn't too tricky I believe, but how do I then say OK, extract that block of text? I'm assuming I need to use the Mid([mytextstring],X,9) (9 from the example above) but how do I set the value of X?

I'm having a bit of a brain dead day and can't figure it out :(

Thanks.
 
To limit results that contain that text I would use the like operator... Unfortunately I don't use the leter and number masks often enough to remember them cold but you should not have a problem finding them in help.

From there, the only thing I can think to do is use a combination of instr, mid, and like to test all the values surrounding a dash... If the format matches it is your value, otherwise find the next one (increment the start value of instr). You might even use the ISNUMERIC function for the number portion.

I hope that is enough to get you going... post back with your results.
 

what character DELIMITS this pattern? Is it a SPACE or what?

Or is it just burried like this...
[tt]
123xc-123abc-1234nyc-12345zwx-1234
[/tt]



Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top