我正在尝试创建一个可以改变它的textmate片段:
HELLO WORLD<br />
SAY ANYTHING
对此:
hello world say anything
任何帮助?
答案 0 :(得分:7)
在Allan Odgaard的帮助下:
begin
in: ${1:Hello}
out: ${1/\A\s+|\s+\Z|\s*\n\s*|(\<br\s*\/?\>)|(.)/(?1: :\L$2)/ig}
end
begin
in: THIS IS<br />
WORKING<BR>
VERY NICELY<br/>
EVEN WITH MULTIPLE<BR />
LINE BREAKS!
out: this is working very nicely even with multiple line breaks!
end
\A beginning of buffer
\s+ followed by one or more whitespace
| OR
\s+ one or more whitespace
\Z followed by end of buffer
| OR
\s* zero or more whitespace
\n followed by newline
\s* followed by zero or more whitespace
| OR
( Capture to 1
<br Literal `<br'
\s* followed by zero or more whitespace
\/? followed by one or zero literal `/'
> followed by literal `>'
) End capture
| OR
( Capture to 2
. Any character
) End capture
注意:条件替换是TextMate唯一的
(?1: IF Capture 1 is found
Insert space (' ')
: ELSE
\L$2 Insert lowercase(Capture 2)
) ENDIF
i case insensitive
g global match/replace