Need Help > TMS WebCore project

Dear Sir or Madam,

I need your assistance with a TMS WebCore project!

I am getting a compiler error. [Fehler] P_RegistrierungBearb.pas(6): can't find unit "System.RegularExpressions"

In the ..pas file,

unit P_RegistrierungBearb;

interface

uses
System.RegularExpressions, //wegen der Passwort-Kontrolle
System.SysUtils, System.Classes,
Vcl.StdCtrls, Vcl.Controls,
....

and the function is:

function TfP_RegistrierungBearb.ValidatePassword(aPassword: String; var ErrorMessage: String): Boolean;
begin
Result := false;
ErrorMessage := '';

if Length(aPassword) <> 9 then
begin
ErrorMessage := 'Password must be exactly 9 characters long';
exit;
end;

if not TRegEx.IsMatch(aPassword, '[a-z]') then
begin
ErrorMessage := 'At least 1 character in the password must be lowercase';
exit;
end;

if not TRegEx.IsMatch(aPassword, '[A-Z]') then
begin
ErrorMessage := 'At least 1 character in the password must be uppercase';
exit;
end;

if not TRegEx.IsMatch(aPassword, '\d') then
begin
ErrorMessage := 'At least 1 character in the password must be a digit';
exit;
end;

if not TRegEx.IsMatch(aPassword, '[!,#,%,&,,@]') then
begin
ErrorMessage := 'At least 1 character in the password must be one of the following letters: !,#,%,&,
,@';
exit;
end;

Result := True;
end;

Is there a way to include System.RegularExpressions into the WebCore project?

Yes, TMS WEB Core includes regular expression functionality through the WEBLib.RegularExpressions unit. You can use this unit to perform regular expression operations, similar to how you would in VCL/FMX applications, but within the context of TMS WEB Core

Hello!

I have a new problem!
If i uses WEBLib.RegularExpressions the sample aPassword := '1234567b';

if not TRegEx.IsMatch(aPassword, '[a-z]') then
begin
ErrorMessage := 'At least 1 character in the password must be lowercase';
exit;
end;

is no match?

But there is a lowercase in '1234567b'!

We could reproduce this and are investigating.

A workaround for now is to use:

var
  aPassword: string;
  FJSRegExp: TJSRegexp;
  res: boolean;
begin
  aPassword := '1234567b';
  FJSRegExp := TJSRegexp.new('[a-z]');
  res := FJSRegExp.test(aPassword);
  console.log('result',res);
end;

Okay, thank you very much!