The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Delphi TRegExOption: Where is description of roNotEmpty option? What does this option do? – Jacek Laskowski – Google+

Posted by jpluimers on 2020/12/10

I really dislike using regular expressions, mainly because every time I bump into code using them either:

  • I cannot decipher them any more
  • It is used for things not suites for (like parsing JSON or XML: please don’t!)

For more background on when NOT to use regular expressions, remember they describe a regular grammar, and can only me implemented by a finite state machine (a state machine that can be exactly one state out of a set of finite states).

As soon as you need to parse something that needs multiple states at once, or the number of states becomes infinite,

Some background reading:

 

 

But it helps knowing that stuff means in the various environments you use, so [WayBack] Delphi TRegExOption: Where is description of roNotEmpty option? What does this option do? – Jacek Laskowski – Google+:

In TregEx.Create:

if (roNotEmpty in Options) then
  FRegEx.State := [preNotEmpty];

preNotEmpty is a TPerlRegExState which is defined as:

TPerlRegExState = set of (
  preNotBOL, // Not Beginning Of Line: ^ does not match at the start of Subject
  preNotEOL, // Not End Of Line: $ does not match at the end of Subject
  preNotEmpty // Empty matches not allowed
);

So roNotEmpty seems to indicate that empty matches are not allowed.

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.