Hi

I'm starting to learn regex and I'm having some problems using it in custom filters. It seems to ignore some regex patterns.

For example:

Text:

afoo bfoo abc acb bca bac

With this search:

/(a|b)(?=foo)/

doesn't match anything.

Where is the problem? Is custom filter using some kind of cut search patterns set?

Comments

mradcliffe’s picture

/([ab]foo?)/i If i replace everything with the word blah this gives me

blah blah blahblahc blahcblah blahcblah blahblahc

I was browsing around and came across this issue so I thought I'd try to help out.

NoRandom’s picture

With your example, /[a|b](foo)/ also seems to work. So, I'm thinking the error is in my search using () instead of [].

I use regex buddy wich helps me a lot to learn and check my search patterns but maybe it's too permissive.

Kind regards.

PD.- Anyway, I tried sometimes to build maybe too long search patterns.

avpaderno’s picture

Component: Documentation » Code
Status: Active » Fixed

/[a|b](foo)/ is quiet different from /(a|b)(foo)/; [a|b] would match a, or b, or | while (a|b) matches a, or b.

NoRandom’s picture

My mistake, KiamLaLuno, sorry.

Anyway, I use Regex Buddy to check my search expresions. Some times the search works in regex buddy and doesn't in custom filter.

avpaderno’s picture

That is strange; they declare to support PHP regular expressions.
The only way I know to verify the regular expression is really working is to test it in PHP code. Take in mind that this module uses PCRE regular expressions, which are different from ereg expressions, and from Perl regular expressions.

NoRandom’s picture

I don't have access right now to regex but as soon as I come back to my computer I try to put an example.

Kind regards.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.