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
Team Powersoft
An...@DelaNET.Com
http://www.delanet.com/~aturians/pbh
http://www.teamps.com
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
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.