Subject Re: manipulating a string
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 22 Mar 2022 17:26:15 +0200
Newsgroups dbase.getting-started

On 2022/03/20 23:29, Lee Grant wrote:
> Mervyn,
>
> Thanks for showing me one way to use my new regex skills in dBASE with
> this example.  I've heard you mention you like using it here, but wasn't
> sure how you did that. Now I know. :)

I first looked at regular expressions when Michael Nuwer published an
article in Issue 20 of the dBulletin back in March 2005.
https://www.jpmartel.com/bulletin.htm

It's a bit of a learning curve but the gain is well worth the pain.

And once one is comfortable with it all sorts of uses come to mind.
I've used it to add HTML tags, remove HTML tags, find URLs in HTML
pages, find telephone numbers in HTML pages, add responses to HTML
pages, highlight words in memo fields, convert UNIX text files to
Windows text files and vice versa, create a list of all my example code
that uses externs and a list of code that uses RegExp.

Most of these tasks can be done using the dBASE string handling
functions.  The RegExp solution is, however, usually significantly less
code and significantly faster.

To use the dBASE functions usually means reading a source file a line at
a time, a check to see if action is needed, if so do it, write the line
back to an output file and then read the next line.  With RegExp one can
read the entire file into memory, do the test which is virtually
instantaneous, and then do the replace which is again virtually
instantaneous. The changed text in memory can then be written out in one
write.

For a single file the time saving may not be significant but if one has
to churn through many files it's different story.

Mervyn.