I'm trying to figure out why the regex code below gives me two different results, depending on where I use it.

[A-Z]{0,1}[a-z]{2,}[:]

On phpliveregex.com, the above regex code matches the following:
narrator:
Narrator:

When used in preg_match, the above regex code matches the following:
narrator:
Narrator:
NARRATOR:

PS I'm not sure this is a relevant forum. I saw a bunch of regex questions on DANIWEB, but now that I'm trying to add my own question, the tags I am offered have nothing to do with PHP or REGEX.

Since you are doing this in Windows, I can't guess if this was in Visual Studio, the powershell command line or something else. But hey, for years folk have noted that Microsoft's implementation doesn't always match (pun intended) what you find in PHP, Linux and other places.

Example read (somewhat deep) at https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7.1&viewFallbackFrom=powershell-6

So if you dig deep enough you will find something.

It is going to match Narrator: or narrator: because you are allowing the first letter to be either case. As for the NARRATOR: match, check to see if you have an ignorecase option that may be True by default. In Python you have to explicitly state IGNORECASE. This may not be so in other implementations.

commented: please a need the code for button next and back search the same string in txt file in vbnet 2013 thanks +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.