search but ignore some chars

Y

YisMan

i need to search a string of chars within a 2nd string but id like to ignore
certain characters in the 2nd string. specifically linefeeds, returnchars and
the like (in vba)

the catch is that i cannot remove [replace func] these chars from the 2nd
string before searching, as my code needs to calculate (after locating the
1st string) at which line/para was the string found.

id appreciate any help in the right direction.
 
K

Klatuu

You question needs some clarification. What do you want to do with the
results of the search? Do you need to know where the 2nd string was found,
if it was found, or change it to something else?
 
L

LanceMcGonigal

You could read the string containing the special chrs into a var without the
special chrs using the replace function and then comparing the first string
to the special var w/o special chrs.

cheers
 
Y

YisMan

thanks its amazing how much help people are willing to give, i appreciate.

my problem though is a drop more. the special chars are actually linefeeds
and after the comparison i want to know which line i'm on which means i do
need the linefeeds, but i cannot search in the string including linefeeds,
whaddai do?
--
Thankfully, YisMan


LanceMcGonigal said:
You could read the string containing the special chrs into a var without the
special chrs using the replace function and then comparing the first string
to the special var w/o special chrs.

cheers

YisMan said:
i need to search a string of chars within a 2nd string but id like to ignore
certain characters in the 2nd string. specifically linefeeds, returnchars and
the like (in vba)

the catch is that i cannot remove [replace func] these chars from the 2nd
string before searching, as my code needs to calculate (after locating the
1st string) at which line/para was the string found.

id appreciate any help in the right direction.
 
L

LanceMcGonigal

Well, actually you have two different vars (the field w/CRLF and w/o).

You could use the one w/o for comparsion and the other for position couldn't
you? All the parts are there.

thanks


YisMan said:
thanks its amazing how much help people are willing to give, i appreciate.

my problem though is a drop more. the special chars are actually linefeeds
and after the comparison i want to know which line i'm on which means i do
need the linefeeds, but i cannot search in the string including linefeeds,
whaddai do?
--
Thankfully, YisMan


LanceMcGonigal said:
You could read the string containing the special chrs into a var without the
special chrs using the replace function and then comparing the first string
to the special var w/o special chrs.

cheers

YisMan said:
i need to search a string of chars within a 2nd string but id like to ignore
certain characters in the 2nd string. specifically linefeeds,
returnchars
and
the like (in vba)

the catch is that i cannot remove [replace func] these chars from the 2nd
string before searching, as my code needs to calculate (after locating the
1st string) at which line/para was the string found.

id appreciate any help in the right direction.
 
J

John Nurick

Can you give a couple of examples of the strings you need to search and
the strings you want to search for? I'm imagining from your previous
post that it might be something like this

Once upon a time there was a little girl called Little<newline>
Red Riding Hood. One day Little Red Riding Hood's mother<newline>
asked her to lorem ipsum loquitur snafu ondon. Little Red<newline>
Riding Hood oritsing logram rheasolly jubber und so weiter...

and you want to locate (or do something with) every instance of "Little
Red Riding Hood" whether there are spaces, line breaks or whatever
between the words. If so, you can do it by writint Access VBA code that
uses the VBScript regular expression engine and a pattern like this:

\bLittle\W+Red\W+\Riding\W+Hood\b

and working with the FirstIndex and Length properties of the Match
objects it returns.

By using a more sophisticated pattern , you can do things like find the
first character of a line (or paragraph) that contains what you're
searching for.

Is that the kind of thing you're after?
 
Y

YisMan

thanks a million, couldnt of given a better example myself!
if you just wouldnt mind to eloborate on this "vbscript regular expressions"
as i havent heard of it ever, and couldnt find anything on access help
a million thanks
 
J

John Nurick

Regular expressions are like wildcards on nitro, and more and more
modern computer languages incorporate them. VBA and classic VB are not
modern languages, but VBScript - another dialect of Visual Basic - does
have a good (though by no means state of the art) regex engine which can
easily be used from Access.

Regexes can also be very subtle and very confusing. A single regex can
save dozens of lines of code - and can be harder to debug until you know
what you're doing! I've collected some links to documentation and
tutorials in the "More about Regular Expressions" page at
http://www.j.nurick.dial.pipex.com/Code/index.htm.
 

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