The JSVerbalExpressions has been very cool to me at first sight few years ago - It does what Regular Expression does, but is *much human-friendly* . The Good news is, today I came across a Delphi implementation, by Tim, from Jena, Germany!
The JSVerbalExpressions has been very cool to me at first sight few years ago - It does what Regular Expression does, but is *much human-friendly* . The Good news is, today I came across a Delphi implementation, by Tim, from Jena, Germany!
Usage example:
var
LobjVerbalExpression : TVerbalExpression;
begin
LobjVerbalExpression := TVerbalExpression.Create
.StartOfLine()
._Then('http')
.Maybe('s')
._Then('://')
.Maybe('www.')
.anythingBut(' ')
.endOfLine();
ListBox1.Items.Add(LobjVerbalExpression.AsString);
if LobjVerbalExpression.Test('https://github.com') then
ListBox1.Items.Add('valid url')
else
ListBox1.Items.Add('invalid url');
end;
https://github.com/enko/DelphiVerbalExpressions
Usage example:
var
LobjVerbalExpression : TVerbalExpression;
begin
LobjVerbalExpression := TVerbalExpression.Create
.StartOfLine()
._Then('http')
.Maybe('s')
._Then('://')
.Maybe('www.')
.anythingBut(' ')
.endOfLine();
ListBox1.Items.Add(LobjVerbalExpression.AsString);
if LobjVerbalExpression.Test('https://github.com') then
ListBox1.Items.Add('valid url')
else
ListBox1.Items.Add('invalid url');
end;
https://github.com/enko/DelphiVerbalExpressions
If you have used RegEx before, you know what I mean :)
ReplyDeletePS, Here is the original JavaScript implementation: https://github.com/VerbalExpressions/JSVerbalExpressions
/sub
ReplyDeleteYes, that's so much easier than regex... thank you for the share
ReplyDeleteI'll take regex every time. They really should be using &Then rather than _Then too
ReplyDeleteGreat! But, I think you could declare &Then() and &Or() instead of _Then() and _Or()
ReplyDelete