Some simple regular expression examples

Share your advanced PureBasic knowledge/code with the community.
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Some simple regular expression example

Post by Kukulkan »

Hi Perkin,

try it and you will get lookbehind assertion is not fixed length error. The assertion must match a fixed length query. Using + and * will never work. You can understand this if you realize that this would need to scan all text previous to this expression. That is impossible and upon this the assertion must be fixed length.

Best

Kukulkan
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Some simple regular expression example

Post by luis »

Kukulkan wrote: The only problem is, that we are not able to handle this (remark the blank after the colon):
Username: Testuser
Username:Testuser
I see your problem. I don't have an idea to solve it (this doesn't say much since I know only the basics of regexes).
Using trim() with the result seem the best thing to do.

Uhm... groups would be sufficient if I'm not mistaken:

Code: Select all

username: Testuser1
username:   Testuser2
username:Testuser3
username:
   testuser4
This

Code: Select all

username:\s*(\w*)
... would match all 4, even the last one and without the unneeded blanks.

I saw your request. Let's hope this will be added to PB.
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply