Skip to content

Instantly share code, notes, and snippets.

@Mark-H
Created August 10, 2011 12:26
Show Gist options
  • Save Mark-H/1136683 to your computer and use it in GitHub Desktop.
Save Mark-H/1136683 to your computer and use it in GitHub Desktop.
Requesting some RegEx help! Modifying Textile behavior.
This regex:
$this->urlch = '[\w"$\-_.+!*\'(),";\/?:@=&%#{}|\\^~\[\]`]';
As part of this in PHP:
return preg_replace_callback('/
(?:^|(?<=[\s>.$pnct\(])|([{[])) # $pre
" # start
(' . $this->c . ') # $atts
([^("|\]]+) # $text
\s?
(?:\(([^)]+)\)(?="))? # $title
":
('.$this->urlch.'+) # $url
(\/)? # $slash
([^\w\/;]*) # $post
(?:([\]}])|(?=\s|$|\)))
/Ux', array(&$this, "fLink"), $text);
Is responsible for parsing out links in Textile if I'm correct.
Normal behavior of textile knows links like this:
"This is a link":http://www.google.com
Now I need to change that to allow a MODX implementation, where in links are generated dynamically by replacing "tags". Something like this needs to work, next to the regular behavior.
"This is a dynamic link":[[~245]]
I've been trying to figure it out but failed so far. I know basic RegEx, but this is way too complex for what I can handle, lol. Any help appreciated..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment