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 2,161 other followers

Archive for October 27th, 2020

Optional sort by name in `LogMemoryManagerStateToFile` · Issue #64 · pleriche/FastMM4 · GitHub

Posted by jpluimers on 2020/10/27

If not done yet, try to improve this: [WayBack] Optional sort by name in LogMemoryManagerStateToFile · Issue #64 · pleriche/FastMM4 · GitHub

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

shell – How do I grep for multiple patterns with pattern having a pipe character? – Unix & Linux Stack Exchange

Posted by jpluimers on 2020/10/27

Since I keep forgetting this – especially because I cannot remember the “why”: [WayBack] shell – How do I grep for multiple patterns with pattern having a pipe character? – Unix & Linux Stack Exchange by “user unknown“.

The -E means using Regular expression: POSIX extended – Wikipedia.

egrep "foo|bar" *.txt

or

grep "foo\|bar" *.txt
grep -E "foo|bar" *.txt

selectively citing the man page of gnu-grep:

   -E, --extended-regexp
          Interpret PATTERN as an extended regular expression (ERE, see below).  (-E is specified by POSIX.)

Matching Control
   -e PATTERN, --regexp=PATTERN
          Use PATTERN as the pattern.  This can be used to specify multiple search patterns, or to protect  a  pattern
          beginning with a hyphen (-).  (-e is specified by POSIX.)

(…)

   grep understands two different versions of regular expression syntax: basic and extended.”  In  GNU grep,  there
   is  no  difference  in  available  functionality  using  either  syntax.   In  other implementations, basic regular
   expressions are less powerful.  The following description applies to extended regular expressions; differences  for
   basic regular expressions are summarized afterwards.

In the beginning I didn’t read further, so I didn’t recognize the subtle differences:

Basic vs Extended Regular Expressions
   In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead  use  the
   backslashed versions \?, \+, \{, \|, \(, and \).

I always used egrep and needlessly parens, because I learned from examples. Now I learned something new. :)

–jeroen

Posted in Development, RegEx, Software Development | Leave a Comment »

delphi – Can I use an Edit Mask to format output? (not just validate input) – Stack Overflow

Posted by jpluimers on 2020/10/27

From a while ago, and – being on the back-end side mostly – I sometimes forget: [WayBack] delphi – Can I use an Edit Mask to format output? (not just validate input) – Stack Overflow

You can use the TField.OnGetText event or TNumericField.DisplayFormat property to modify how the text is being displayed.

Since you have a TStringField holding numbers, you have two choices:

  • use a TNumericField and the DisplayFormat property
  • use the OnGetText event and do your own string formatting

Edit:

Sam used this approach:

I implemented OnSetText and OnGetText event handlers. I already had the Edit Mask 9999 9999 9999 9999;1;_ so the OnSetText was just

TStringField(Sender).Value := Trim(Text);

and OnGetText was just

sValue := TStringField(Sender).Value;  
Text := Format('%s %s %s %s', [Copy(sValue, 1, 4), Copy(sValue, 5, 4), Copy(sValue, 9, 4), Copy(sValue, 13, 4)]);

It works fine. Thanks.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

 
%d bloggers like this: