This regex should be matching anything from 400.00 to 999.00

\b[4-9][0-9][0-9]\.

Confirmed working by http://gskinner.com/RegExr/ regex build helper.

However in a textual comparison with regex clicked on, this regex will not match any text. Even text pasted from regex build helper that had been confirmed to match the regex will not match when implemented in rules.

Through experimentation, I have determined that it is failing to match the beginning of string character. Removing that character from the regex will cause it to work as it should (though not as we want it to as now it matches a number of any size so long as it includes the sequence of character xxx. thus it would match 500000400.)

Pretty sure this is a bug so I am not labeling it as such. I apologize if I'm missing something but the logic seems airtight to me.

Comments

melchoir55’s picture

Component: Rules Core » Rules Engine

update:

I have determined why the regex isn't working. When viewing an export of the rule, we see

\\b[0-3][0-9][0-9]\\.

note that both \b and \. have been escaped. I cannot imagine why rules is automatically escaping backslashes. I'm going to go look at module code and post back if I figure it out.

melchoir55’s picture

Title: regex bug will not match beginning of string » regex bug automatically escapes \ characters

updating title to reflect problem

Edit:

I have literally gone through every single file in the rules module searching for instances of the '\' character and checking to see whether it is being targeted for any modification of any kind.

I have found absolutely nothing to explain why this bug is happening. Does anyone have any idea what is going on?

fago’s picture

Status: Active » Closed (cannot reproduce)

As this bug-report is rather old, please verify it's still valid in the latest dev version and re-open if so. For now, I'm marking it as closed.