[TxMt] Compound regular expressions in snippets

Allan Odgaard throw-away-1 at macromates.com
Fri Jul 6 12:05:34 UTC 2007

On 6. Jul 2007, at 12:35, Jordan Harper wrote:

> Basically, I want to replace all spaces in a tab-stop with hyphens,  
> whilst also lowercasing the whole string -- two things I can  
> happily do separately:
> ${1/.*/\L$0/}
> ${1/ /-/\g}
> but can't seem to work out if it's possible to do both at the same  
> time [...]

One workaround is to use conditional insertions, e.g.:

     ${1/( )|[^ ]+/(?1:-:\L$0)/g}

If we match a space (capture 1), we insert a hyphen, otherwise we  
insert the match as lowercased.

More information about the textmate mailing list