Page 2 of 2

Re: Some simple regular expression example

Posted: Tue Sep 04, 2012 1:01 pm
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

Re: Some simple regular expression example

Posted: Wed Sep 05, 2012 11:36 pm
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.