regex - brain fart or bug in 6.02?

Just starting out? Need help? Post your questions and find answers here.
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

regex - brain fart or bug in 6.02?

Post by jassing »

Why is this generating an extra character?

Code: Select all

CreateRegularExpression(0,"[0-9]*$")
Debug ReplaceRegularExpression(0,"test","") 
Debug ReplaceRegularExpression(0,"test0","") 
gives me "testt" (unexpected) and "test" (expected)

Seems to work as-expected with 6.01x86, 6.00x64, so maybe a bug with 6.02?
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: regex - brain fart or bug in 6.02?

Post by jacdelad »

What exactly do you want to achieve?

Whot into the blue:

Code: Select all

CreateRegularExpression(0,"[0-9]+")
Debug ReplaceRegularExpression(0,"test","") 
Debug ReplaceRegularExpression(0,"test0","") 
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: regex - brain fart or bug in 6.02?

Post by STARGÅTE »

jassing wrote: Thu Jun 01, 2023 3:46 am Seems to work as-expected with 6.01x86, 6.00x64, so maybe a bug with 6.02?
Confirmed.

Code: Select all

CreateRegularExpression(0,"[0-9]*$")
Debug ReplaceRegularExpression(0,"test","_|") 
Debug ReplaceRegularExpression(0,"test0","_|") 
test_|t_|
test_|_|
There is an additional character, which should not be there.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: regex - brain fart or bug in 6.02?

Post by jassing »

jacdelad wrote: Thu Jun 01, 2023 4:37 am What exactly do you want to achieve?
I thought that was self-evident... I wanted to know if what I have distilled down is a problem for me, or purebasic. So I posted sample code to illustrated a problem.
jacdelad wrote: Thu Jun 01, 2023 4:37 amWhot into the blue:
what is "whot" in this context?
STARGÅTE wrote: Thu Jun 01, 2023 5:50 am Confirmed.
Thank you. I'll post to the bug forum...
STARGÅTE wrote: Thu Jun 01, 2023 5:50 am There is an additional character, which should not be there.
it appears to always be the last character of the string being manipulated.
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: regex - brain fart or bug in 6.02?

Post by jacdelad »

Whot is the same as Shot. :mrgreen:

However, RegEx101.com handles it the same way as PureBasic 6.02, so I suspect that the earlier versions handled it wrong!
Image
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: regex - brain fart or bug in 6.02?

Post by jassing »

jacdelad wrote: Thu Jun 01, 2023 7:08 am
However, RegEx101.com handles it the same way as PureBasic 6.02, so I suspect that the earlier versions handled it wrong!
You need to do replace, not a search.
Yes, it matches the # - that's the point, but in purebasic 6.02 it adds an extra character that isn't specified.
Image

Regex101 indeed, does it correctly.

Image
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: regex - brain fart or bug in 6.02?

Post by jacdelad »

Yes, you're right.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply