Re: How do I find strings with wildcards?
From: anon (aslkfj39_at_yahoo.com)
Date: 03/15/04
- Previous message: VBDis: "Re: C to Delphi set problems"
- In reply to: anon: "Re: How do I find strings with wildcards?"
- Next in thread: Bruce Roberts: "Re: How do I find strings with wildcards?"
- Reply: Bruce Roberts: "Re: How do I find strings with wildcards?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 14 Mar 2004 15:38:29 -0800
<snip>
> > > You need to define what you are really after a bit more clearly
> > Ok, I've done a lot of work on it and I've come up with the following, you
> > should be able to get an idea of what im attempting to do:
<snip>
> > If you dont understand anything/have questions about what im trying to do
> > etc please post! The above is in a very simple scripting language that
> > everyone that knows delphi should be able to understand.
> >
> > As always, thank you for your time!
>
> -- Updated Code --
>
> After finding and fixing a bunch of errors, I am now unable to find
> anymore and it still does not work correctly!
<snip>
-- Updated Code [2nd time] --
I'm trying to make a function that picks up a word with an optional
offset in a string. if the offset is zero then the function will just
search for the word but if the offset is a number, lets say one, then
it should search for that word with the offset one. lets look at an
example:
string: this is a test
word: test
offset: 1
if the following words are present in string then they should return
the value found because of the offset being one, the character x is
used to represent any possible single character:
test
txest
texst
tesxt
xest
txst
text
tesx
My function is able to pick up almost all of the above but it has
problems with things like texst because no matter where i put the word
test under it three characters will not line up. Please tell me how to
modify my code to make it work correctly.
//{-- the updated code /sunday/march 14/2004/}
function filter takes string source, string word, integer offset
returns string
local integer loop_source = 1
local integer loop_word = 1
local integer match = 0
loop
exitwhen (loop_source > StringLength(source))
if (SubStringBJ(source, loop_source, loop_source) == SubStringBJ(word,
loop_word, loop_word)) then
set match = match + 1
set loop_source = loop_source + 1
set loop_word = loop_word + 1
if (match >= StringLength(word) - offset) then
return "found"
endif
else
set loop_source = loop_source + 1
set loop_word = loop_word + 1
endif
if (loop_word >= StringLength(word) ) then
set loop_source = ((loop_source + 1) - StringLength(word))
set loop_word = 1
set match = 0
endif
endloop
return "not_found"
endfunction
- Previous message: VBDis: "Re: C to Delphi set problems"
- In reply to: anon: "Re: How do I find strings with wildcards?"
- Next in thread: Bruce Roberts: "Re: How do I find strings with wildcards?"
- Reply: Bruce Roberts: "Re: How do I find strings with wildcards?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|