Escaping regex + character
Hi All, Just a quick question - I've compiled FR3 with pcre regex libraries and it's working ok. I just can't get it to escape plusses ( + ) though I've tried between 0 and 6(!) backslashes but all result in: ERROR: Failed compiling regular expression: bad range inside [] at offset 10 (0) ERROR: Condition evluation failed because the value of an operand could not be determined It's the + in the character class I'm trying to escape. This is with two backslashes (what I'd expect to work as it does with dots - \\. (0) ? if ("%{Email-Address}" =~ /^[a-z0-9_-\+]+(\.[a-z0-9_-\\\+])*@[a-z0-9_-\\\+]+(\.[a-z0-9_-\\\+]+)*(\ .[a-z]{2,4})$/) (0) expand: "%{Email-Address}" -> 'a+b@c.de' ERROR: Failed compiling regular expression: bad range inside [] at offset 10 (0) ERROR: Condition evluation failed because the value of an operand could not be determined The regex works ok without the plusses, if not including them in the subject.. Thanks Andy
On 22 Aug 2013, at 23:02, Franks Andy (RLZ) IT Systems Engineer <Andy.Franks@sath.nhs.uk> wrote:
evluation
Well at least it'll evaluate instead of evluate now. In the regex below it's not complaining about the lack of escaping. It's complaining that _-+ or _-\ is not a valid range (I honestly can't remember if FR and PCRE both consume backslashes where the subsequent char doesn't need to be escape), which I believe is correct. You can only specify ranges of numbers or letters, not symbols. If you want to specify symbols you have to specify them individually or use one of the predefined sets. Or if you shift that hyphen one to the right, it'll probably work OK too :) For future reference those regex compilation errors are coming from the PCRE library, so you can look at the char offset after the first / to see where the error is occurring. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team
participants (3)
-
Arran Cudbard-Bell -
Franks Andy (RLZ) IT Systems Engineer -
Phil Mayers