search and match TEXT and return what is leftover?

  • Thread starter robertadamharper
  • Start date
R

robertadamharper

Hi
I have a list of text values within a field in access and I want to
return the text that appears to the left of that it the field value
matches specific text?

eg.

Value
"www.google.co.uk/search?hl=en&q=hazard signs&meta="

if the value matches "search?hl=en&q" return what is to the left of
that up until the "&meta="

Answer
Would return "=hazard signs"

Many Thanks
 
M

Marshall Barton

I have a list of text values within a field in access and I want to
return the text that appears to the left of that it the field value
matches specific text?

eg.

Value
"www.google.co.uk/search?hl=en&q=hazard signs&meta="

if the value matches "search?hl=en&q" return what is to the left of
that up until the "&meta="

Answer
Would return "=hazard signs"


This kind of parsing requires a strict set of syntax rules.
For the simple rule you provided, the code could be
something like:

start = InStr(value, part1) + Len(part1)
end = InStr(start, value, part2)
answer = Mid(value, start, end - start)

You will need to add code to check for either part no
matching, nothing between the parts, etc.

Be sure to check VBA Help for details about the InStr and
Mid functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top