Closed (fixed)
Project:
Custom filter
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Dec 2008 at 20:30 UTC
Updated:
26 Apr 2009 at 02:40 UTC
I can't figure out how to do [[link|text]], I got regular [[link]] like this.
Pattern: /\[\[([^\n]+?)\]\]/i
Replacement text:
$text = $matches[1];
return "$text";
Can somebody help me please? Thanks.
Comments
Comment #1
Flying Drupalist commentedwhoops, the replacement text is like this:
Comment #2
arhip commentedYou can explode the matched text
or use new regex
/\[\[([^\n\|]+?)(\|([^\n]+?))?\]\]/iComment #3
Flying Drupalist commentedHi and thanks arhip, but I don't think those work if you don't use the | pip. [[Link]] breaks.
Comment #4
ged3000 commentedDo you mean that you want [[link]] to work as well as [[link|text]]?
Using the regex that arhip provided will detect [[link]] and [[link|text]], so you just need to make your return a bit cleverer:
Comment #5
Flying Drupalist commentedThanks a lot!