StrPos() case (in)sensitive Regex - not working for [sets]

Tags: #<Tag:0x00007f2253bcd2a8>
RedirFile              FILE,DRIVER('ASCII'),NAME(Glo:FilePath),PRE(RED),CREATE,BINDABLE,THREAD
Record                   RECORD,PRE()
Line                     STRING(4096)
                         END
                     END 

Loc:RegExSection                                  CSTRING(1024)
    Code
Loc:RegExSection        = '\[[a-zA-Z0-9 ]+\]' !Works
Loc:RegExSection        = '\[[A-Z0-9 ]+\]' !Doesnt work
Loc:StrPos = StrPos(Red:Line,Loc:RegExSection,1)

So according to the help docs, the mode in the strpos() is supposed to be a case sensitive toggle or switch. 0 or False = case sensitive, 1 or True = not case sensitive.

So when I use the 2nd Loc:RegExSection, with mode= true, it doesnt work, I have to use the lower case a-z range which is seen in the first Loc:RegExSection to get it to work.

Are there certain things which prevent “not case sensitive” searches from working like using a [a-z] range?

TIA

Hi Richard

This is the same with the Match statement where Match:NoCase does not apply to character sets.

if that is what you want then you are better off either using upper or lower:

Loc:StrPos = StrPos(upper(Red:Line),upper(Loc:RegExSection))

or if you are setting Loc:RegExSection then make that upper yourself:

Loc:RegExSection = ‘[[A-Z0-9 ]+]’
Loc:StrPos = StrPos(upper(Red:Line),Loc:RegExSection)

some people prefer upper() and some prefer lower(). Six of one and half a dozen of the other really.

1 Like

Yeah I know that is an option, reason I ask, when I hit this problem months ago, I did try to find/work out what was the underlying regex “engine”, ie was it using the MS regex ie
Regular Expression Language - Quick Reference | Microsoft Docs
Regular Expressions (REGEX): Introduction - Scripting Blog (microsoft.com)
or a Posix variant, of which a few different one’s exist
Regular expression - Wikipedia
or whether it is was a Topspeed inhouse version.

I’ve never been able to find that one out, does anyone know?

I suspect it is an inhouse version cooked up by Alexey years back.

Clarion uses non-standard curly braces{} rather than parentheses() for grouping. This was originally wrong in the documentation but was subsequently corrected after I had an email exchange with Alexey probably more than 20 years back now.

The reason curly braces are a PITA is that you need to “double-up” the opening brace and hence your regex no longer looks symmetrical.

For more on this have a look at two articles by me in Clarion Magazine November 2002:

Determining Gender With Clarion (Part 1) and
Determining Gender With Clarion (Part 2)

I think it was Nigel Hicks that made it from a C++ library, but as you noted it is Clarion flavored.

thanks Carl - I didn’t know Nigel Hicks had done it.

When Nigel passed away in 2011, Clarion Magazine reported:

Nigel was a co-founder of JPI and the Director of Product Development at the London Development Centre. He developed the original Clarion IDE framework and the Report Writer. He was also the development team leader when SoftVelocity acquired the Clarion product line. Nigel contributed greatly to Clarion’s success over the years.

I think it was back in early C5 I was working with Match() and reported a few bugs. Nigel was kind enough to email me a fixed Run DLL and some helpful tips. IIRC one bug was wildcards with double asterisks would GPF.

The should be a Cmag article with MatchMaker to test expressions.

I’ve been using them for a bit
!Loc:RegExSection = '\[{{8|16|32|64|DEBUG|RELEASE|COMMON|DEBUG8|RELEASE8|DEBUG16|RELEASE16|DEBUG32|RELEASE32|DEBUG64|RELEASE64}\]'
Loc:PatternMatch = '^#{{if|IF|If} ...'
Loc:PatternMatch = '^#{{else|ELSE|Else}'

whilst also making sure they dont get treated as a double curly brace
Loc:PatternMatch = '^typedef struct [A-Za-z_]+ \{{'

I’ll check them out, but has anyone built some sort of regex builder from data examples, that anyone knows of?

I’m assuming this is some sort of regex builder so if it is, I’ll check that out.

Nigel sounds like he was an amazing person. Richard Chapman mentioned Nigel had pretty well invented TSR’s when he developed Borland’s Sidekick.

Terminate Stay Resident? I had some of those in the dos days, played a few jokes on people with them :grinning: one sounded like a garbled taxi radio coming through the pc speaker at random times, relying on peoples lack of knowledge on electrical interference during the 8086’s 80286’s times.

yes exactly. I remember using Sidekick way back in the DOS days

According to the prospectus for Borland’s initial public offering of stock to the public, Sidekick sold more than 1 million copies in its first three years

It doesnt seem like a lot, but back then money was worth something unlike the worthless experiment it is today.

What I also find interesting is how the window interface was what people were gravitating to using the ascii symbols 191-197, 185-188 and 200 - 206.

For me with no internet or bbs of any sorts, no one to ask, not even teachers could help me because I was at school at the time with my acquired copy of CPD2.1, I had to figure this all out myself, switch flicking effectively that required a lot of patience, but that was still better than some other alternatives and I saw the potential in these early computers. I wrote my first flat file database on a commodore 64 whilst at primary school, no one was interested! :roll_eyes:

But considering everything has gone the window gui look and feel, I do think there is another stage of development or evolution to come. I mean web browsers are basically mainframe terminals with a few more bells and whistle where the mainframe is the webserver running over the internet with a massive reliance on security.

I used to use Mitten’s Quickref. It was quirky, but useful.

CLARION TIPS AT YOUR FINGERTIPS

Quik Reference has tips and examples not contained in the manuals.Get a complete on-line language reference for both Versions 2.1 and 3.0. Find language changes quickly and easily. Commands that are new, changed or removed are all indexed with syntax, usage, tips, and examples.Save time and eliminate clutter. Get information at the touch of your hot key. Installs and removes easily, or run stand-alone.Hypertext engine needs only 1Kb conventional memory and supports a mouse. Only $49.

2 Likes