Re: wildcard_match question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Pete Lomax wrote:
> 
> Salix wrote:
> > 
> > 
> > }}}
<eucode>
> > include wildcard.e
> > ? wildcard_match("*ema*l*","  the email address")
> > ? wildcard_match("*ema*l*","* the email address")
> > </eucode>
{{{

> > 
> > Is it meant to work like this? I thought string st2 ("* the email address")
> > matches pattern st1 ("*em*l*") in the second case.
> > 
> I took a quick look at this. What is happening is that the * in st2 is being
> treated as a literal match against the first * in st1, and hence that first
> * is no longer treated as a wildcard. I noted that
> }}}
<eucode>
> ? wildcard_match("*ema*l*","*email address")
> </eucode>
{{{

> prints 1 because st1 and st2 begin with the literal "*ema". I also tried:
> }}}
<eucode>
> ? wildcard_match("*ema*l*"," *the email address")
> </eucode>
{{{

> which also prints 1, so obviously a * in st2 does not have to literally match
> and "absorb" a * in st1.
> 
> I haven't tested this properly, but I think the following might fix it - any
> comments Rob? In wildcard_match(), replace
> }}}
<eucode>
>  if not find(pattern[p], {str[f], '?'}) then
> </eucode>
{{{

> with
> }}}
<eucode>
>  integer pp
>    pp = pattern[p]
>    if pp='*' or (pp!=str[f] and pp!='?') then
> </eucode>
{{{

> or possibly, since the routine appears as if it would work with complex nested
> sequences as well as plain character strings (and why not):
> }}}
<eucode>
>  object pp
>    pp = pattern[p]
>    if equal(pp,'*') or (not equal(pp,str[f]) and not equal(pp,'?')) then
> </eucode>
{{{


Thanks for looking into this.
I haven't looked at this code in 15 years.
If you think you have a good fix, feel free to check it in.
(TortoiseSVN is easier than you think to set up! smile)

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu