Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-10

any free pascal standard function to compare a string against an array of string?

4 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

OBones
to Dennis

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

Dennis wrote 14 lines
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  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

David Copeland
to Dennis: is there a function like   if    IsOneOf('subtext', ['abc','cde','fecg','hig'])  …

Dennis,

Look at AnsiMatchStr in strutils.

Dave.

Dennis wrote 14 lines
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  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
David Copeland JSI Data Systems Limited 613-727-9353 www.jsidata.ca

Reply by email

Michael Van Canneyt
to Dennis: is there a function like   if    IsOneOf('subtext', ['abc','cde','fecg','hig'])  …
Dennis wrote 9 lines
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.

Reply by email