Discussion:
[fpc-pascal] any free pascal standard function to compare a string against an array of string?
Dennis
2018-10-10 15:11:48 UTC
Permalink
is there a function like
  if    IsOneOf('subtext', ['abc','cde','fecg','hig'])   then begin
...
end;

is there such a function IsOneOf(TheSubString : String; const TheStrings
: array of String) : Boolean
?
if yes, what is its name and unit?

Dennis
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/m
Michael Van Canneyt
2018-10-10 15:31:23 UTC
Permalink
Post by Dennis
is there a function like
  if    IsOneOf('subtext', ['abc','cde','fecg','hig'])   then begin
...
end;
is there such a function IsOneOf(TheSubString : String; const TheStrings
: array of String) : Boolean
?
if yes, what is its name and unit?
IndexStr in strutils:

https://www.freepascal.org/docs-html/current/rtl/strutils/indexstr.html

Michael.
OBones
2018-10-10 15:17:04 UTC
Permalink
Hello,

I would use IndexStr from StrUtils:
https://www.freepascal.org/docs-html/rtl/strutils/indexstr.html

  if IndexStr('subtext', ['abc','cde','fecg','hig']) >= 0  then

Regards
Post by Dennis
is there a function like
  if    IsOneOf('subtext', ['abc','cde','fecg','hig'])   then begin
...
end;
is there such a function IsOneOf(TheSubString : String; const
TheStrings : array of String) : Boolean
?
if yes, what is its name and unit?
Dennis
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mai
David Copeland
2018-10-10 15:29:57 UTC
Permalink
Dennis,

Look at AnsiMatchStr in strutils.

Dave.
Post by Dennis
is there a function like
  if    IsOneOf('subtext', ['abc','cde','fecg','hig'])   then begin
...
end;
is there such a function IsOneOf(TheSubString : String; const
TheStrings : array of String) : Boolean
?
if yes, what is its name and unit?
Dennis
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
--
David Copeland
JSI Data Systems Limited
613-727-9353
www.jsidata.ca

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepa
Loading...