search and match TEXT and return what is leftover?

  • Thread starter Thread starter robertadamharper
  • Start date 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
 
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.
 
Back
Top