Hello.
I am a newcomer to the world of Textmate having previously designed websites with Dreamweaver. I love the snippet functionality and have set about creating loads of my own snippets for speedy XHTML coding. I've hit a small snag whilst trying to get a regular expression to reproduce text in two places in my snippet. The problem I am having is trying to tell it to replace any spaces with say an underscore _ character. Forgive me if this is easy to do, I am quite new to Regular Expressions and I'm still feeling my way!
Here is the offending snippet:
<form action="${1:${TM_FILENAME/(.*?)\..*/$1_submit/}}" method="${2:post}" accept-charset="utf-8"> <fieldset id="${6:${3/[[:alpha:]]+|( )/(?3:_:\L$0)/g}}" ${4:class="${5:}"}> <legend>${3:enter form name}</legend> $0 <button type="submit">submit</button><br/> </fieldset> </form>
So placeholder number 3 is the legend name and also populates the fieldset ID. I can easily change the ID manually if it contains spaces, but I thought it would be really cool if it would just replace them automatically with an underscore instead.
Any help would be much appreciated!
Kind regards,
Ian
On 20 Feb 2009, at 14:07, Ian Alexander Wood wrote:
[...]
<fieldset id="${6:${3/[[:alpha:]]+|( )/(?3:_:\L$0)/g}}" ${4:class="$ {5:}"}>
Here I think you want: ${3/[[:alpha:]]+|( )/(?1:_:\L$0)/g}
The capture registers are local for the replacement, not related to the placeholder enumeration.