Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Match function

58 views
Skip to first unread message

Dean R Bostic

unread,
Jan 19, 1999, 3:00:00 AM1/19/99
to
Often I have a need to do something like this:
if state_code = "NC" or state_code = "NJ" or state_code = "ND" or
state_code = "NY" then...

If it's a one character code I can use Match to do this:
If Match(status,"[AEIOU]") then....

But how do I use Match when there is more than one byte in the string? I
even thought about something like this but it has some subtle limitations
(like when the code is variable length, and you might inadverdently match
on a substring):
If Pos("NC.NJ.ND.NY",state_code) > 0 then...

Any suggestions?
--

Dean R Bostic
drb65812(at)glaxowellcome.com


Andy Turiansky [TeamPS]

unread,
Jan 19, 1999, 3:00:00 AM1/19/99
to
In article <01be43c1$f80ea110$989b3398@us0050720>,
drb65812@_remove_glaxowellcome.com says...

> But how do I use Match when there is more than one byte in the string?
>
I don't think Match alone can handle it. YOu could test for the 1st 2
positions, but then you'd have to loop to test the other values.
--

Andy Turiansky
Team Powersoft
An...@DelaNET.Com
http://www.delanet.com/~aturians/pbh
http://www.teamps.com

Sam Maxwell

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
I often find myself doing something like the following...

ls_match_list='NC,ND,NJ,NY'
ls_match_value='NY'

if Pos(',' + Upper(ls_match_list) + ',',',' + Upper(ls_match_value) + ',')>0
then...

Namely I use comma separated lists. I prepend and append a comma to the
list. I also prepend and append a comma to the value to search for.

This techinique handles variable length values. It avoids some common
errors. But it isn't bullet-proof.

Dean R Bostic wrote in message <01be43c1$f80ea110$989b3398@us0050720>...


>Often I have a need to do something like this:
>if state_code = "NC" or state_code = "NJ" or state_code = "ND" or
>state_code = "NY" then...
>
>If it's a one character code I can use Match to do this:
>If Match(status,"[AEIOU]") then....
>

>But how do I use Match when there is more than one byte in the string? I

avron polakow

unread,
Jan 24, 1999, 3:00:00 AM1/24/99
to Dean R Bostic
NO PROBLEM AT ALL!!

The MATCH() function uses pretty standard REX (Regular Expression) syntax
with straightforward concatenation.

So if you are checking a string which begins with N followed by Y or J or D
just use:

boolean lb_test
lb_test = Match(as_source, "[N][YJD]")

Of course would have been useful if the MATCH() function was like the POS()
function and returned an integer
with the position of the match, and had a second optional int4eger argument
for where the match was to begin.

WARNING:
There used to be a bug in PB4 that if you try to use MATCH() on very LARGE
files,
or when many applications are open when the match is performed.
PB would return the wrong answer and there seem to be memory leaks.

This might have been fixed up, but I would check it out. I don't think it
would ever effect small string matches.

avron polakow

unread,
Jan 24, 1999, 3:00:00 AM1/24/99
to drb6...@_remove_glaxowellcome.com

avron polakow

unread,
Jan 24, 1999, 3:00:00 AM1/24/99
to
0 new messages