TextMate Snippet to Mirror Only Matched Characters
I have been trying unsucces开发者_StackOverflowsfully to mirror text that only matches "a-z0-9" using the following code:
${1/[a-z]/$0/}${1}
After the snippet has been tab triggered I would expect to type "$test" and see "test" mirrored.
Any clues? Many thanks!
The snippet beneath removes all $, % and ? from either beginning or end of your text. Note that the regular expression is added and applied to the mirror, not to the input itself.
$1 ${1/[\$\?%]*([^\$\?%]*)[\$\?%]*/$1/} $0
If you want to exclude more characters, add those to each class (escape them if necessary).
精彩评论