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

Comments

  1. If you have used RegEx before, you know what I mean :)
    PS, Here is the original JavaScript implementation: https://github.com/VerbalExpressions/JSVerbalExpressions

    ReplyDelete
  2. Yes, that's so much easier than regex... thank you for the share

    ReplyDelete
  3. I'll take regex every time. They really should be using &Then rather than _Then too

    ReplyDelete
  4. Great! But, I think you could declare &Then() and &Or() instead of _Then() and _Or()

    ReplyDelete

Post a Comment