Closed (fixed)
Project:
Custom filter
Version:
5.x-1.x-dev
Component:
Miscellaneous
Priority:
Minor
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Oct 2007 at 19:34 UTC
Updated:
15 Jul 2009 at 15:00 UTC
Hi,
No match to your Regex skills. Actually I'm not a developer ;)
1. I'd like to replace [piece| Lorem Ipsum] with <div class="piece">Lorem Ipsum</div>
2. Replace [node=120| Lorem Ipsum] with <a href="/node/120">Lorem Ipsum</a>
Comments
Comment #1
arhip commentedTry this:
/\[(.*?)\s*\=\s*(.*?)\s*\|\s*(.*?)\s*\]/(basically/\[(.*?)\=(.*?)\|(.*?)\]/, but \s* here used to ignore spaces)<a href="$1/$2">$3</a>/\[\s*(.*?)\s*\|\s*(.*?)\s*\]/(basically/\[(.*?)\|(.*?)\]/)<div class="$1">$2</div>And make sure 2 weights more than 1.
We should use \ in front of characters [, ], |, because if not, these characters are used by regex for a special purpose. And (.*?) means, "match any character (except newline)". Every character matched within parenthesis can be retrieved by mentioning $n: $1 for first parenthesis, $2 for the second, and so on. $0 is the whole string matched.
Comment #2
avpadernoI am setting the report as fixed because it got an answer.
Comment #3
avpaderno