On 02/02/2008, George V. Reilly <[EMAIL PROTECTED]> wrote:
>
> I'm trying to write some syntax highlighting for PBwiki, and I'd like to
> reuse some complex regexps. Here are some concrete examples:
>   http://pbwiki.com  -and-  
> [http://pbwiki.com/|PBwiki<http://pbwiki.com/%7CPBwiki>
> ]
>   [EMAIL PROTECTED]  -and-  [EMAIL PROTECTED]|help me harder!!]
>
> I have the following redundant expressions:
> syntax match pbwikiLink
> `\(https\?\|ftp\|mailto\|file\):\(\(\(//\)\|\(\\\\\)\)*[A-Za-z0-9:[EMAIL 
> PROTECTED]/;$~_?+-=.&\-\\\\]*\)`
> syntax match pbwikiLink
> `\[\(https\?\|ftp\|mailto\|file\):\(\(\(//\)\|\(\\\\\)\)*[A-Za-z0-9:[EMAIL 
> PROTECTED]/;$~_?+-=.&\-\\\\]*\)|[^]].\{-}\]`
> syntax match pbwikiLink
> [EMAIL PROTECTED],4}`
> syntax match pbwikiLink
> [EMAIL PROTECTED],4}|[^]].\{-}\]`
>
> How do I reuse the URL regexp and the email regexp inside the
> [<url>|<friendly text>]?
>

Szabolcs kindly pointed me towards
http://groups.google.com/group/vim_use/browse_thread/thread/84f1fa50633c6c50
where Dr. Chip suggested using a combination of :let and :exe.

In my case that yields the more legible

let
s:re_url='\(https\?\|ftp\|mailto\|file\):\(\(\(//\)\|\(\\\\\)\)*[A-Za-z0-9:[EMAIL
 PROTECTED]/;$~_?+-=.&\-\\\\]*\)'
let s:re_email='[EMAIL PROTECTED],5}'
let s:re_linkname='[^]].\{-}'

exe 'syntax match pbwikiLink `' . s:re_url . '`'
exe 'syntax match pbwikiLink `\[' . s:re_url . '|' . s:re_linkname . '\]`'
exe 'syntax match pbwikiLink `' . s:re_email . '`'
exe 'syntax match pbwikiLink `\[' . s:re_email . '|' . s:re_linkname . '\]`'
-- 
/George V. Reilly
http://www.georgevreilly.com/blog

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui