Some Regex patterns doesn't work

Macarro - June 22, 2008 - 12:38
Project:Custom filter
Version:5.x-1.2
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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?

#1

mradcliffe - July 4, 2008 - 03:47

/([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.

#2

Macarro - July 31, 2008 - 12:24

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.

#3

kiamlaluno - July 1, 2009 - 14:11
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.

#4

Macarro - July 5, 2009 - 15:19

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.

#5

kiamlaluno - July 5, 2009 - 20:09

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.

#6

Macarro - July 7, 2009 - 16:36

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.

#7

System Message - July 21, 2009 - 16:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.