[TxMt] Snippet’s $variables in RegExp

riddle riddlu at gmail.com
Sun May 18 13:18:58 UTC 2008


Hi, I’m trying to use ${5:helper text} variable in my regular expression
later in the code:

${5/(e)|(.*)/(?1:\te.preventDefault\(\);\n)(?2:)/}})

What I do here? I check if $5 equals "e" and if it does, I append
".preventDefault();" to my "e". But I’d like to write something like this:

${5/($5)|(.*)/(?1:\t$5.preventDefault\(\);\n)(?2:)/}})

Which simply means I’d like users to be able to change "e" into, for example
"event".

My whole snippet, for better understanding:

bind('${1:event name}'${2:, ${3:passed object}}, function(${4:e}) {
	${0:$TM_SELECTED_TEXT}
${4/(e)|(.*)/(?1:\t\/$4.preventDefault\(\);\n)(?2:)/}})

-- 
View this message in context: http://www.nabble.com/Snippet%E2%80%99s-%24variables-in-RegExp-tp17302873p17302873.html
Sent from the textmate users mailing list archive at Nabble.com.




More information about the textmate mailing list