Check a string correspondence for the specified regular expression.

 

Syntax

function RegExpIsMatch(sInpString, sRegExp: string): boolean;

 

Parameters and return values

Parameter

Type

Value

sInpString

string

string which correspondence you need to check;

sRegExp

string

text of the regular expression.

 

Function result

"True", if a string corresponds to the regular expression, "False" — if not.

 

Example

procedure Check(const sInput: string);
var
  bFlag: boolean;
  s: string;
begin
  bFlag := RegExpIsMatch(sInput, '^\s*[-+]?[0-9]*\.?[0-9]+\s*$');
  
    if bFlag then s := 'TRUE'
      else s := 'FALSE';
      
  mLogScript(sInput, s);
end;
begin
  mLogScript('Regular expression for value of string validation', '');
  
  Check('2.334');
  Check('150.2');
  Check('0.23');
  Check('3');
  Check('3..42');
  Check('4-2.3');
  Check('e5.64');
  Check('3 145');
end.

Script work result

[10:55:00] (Log "RegExpIsMatch"): Regular expression for value of string validation

[10:55:00] (Log "RegExpIsMatch"): [TRUE] 2.334

[10:55:00] (Log "RegExpIsMatch"): [TRUE] 150.2

[10:55:00] (Log "RegExpIsMatch"): [TRUE] 0.23

[10:55:00] (Log "RegExpIsMatch"): [TRUE] 3

[10:55:00] (Log "RegExpIsMatch"): [FALSE] 3..42

[10:55:00] (Log "RegExpIsMatch"): [FALSE] 4-2.3

[10:55:00] (Log "RegExpIsMatch"): [FALSE] e5.64

[10:55:00] (Log "RegExpIsMatch"): [FALSE] 3 145

[10:55:00] (Run "RegExpIsMatch"): Script operation time: 13 ms

[10:55:00] (Run "RegExpIsMatch"): Script done successfully.

 

See also

mLogScript