开发者

TextMate Snippet to Mirror Only Matched Characters

开发者 https://www.devze.com 2022-12-09 19:26 出处:网络
I have been trying unsucces开发者_StackOverflowsfully to mirror text that only matches \"a-z0-9\" using the following code:

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消