Howdy; Finally getting around to tweaking some html snippets, and I'm stuck -
this is what I have: <li id="${1}"><a href="#">$1</a></li>$2
what I'm trying to accomplish is (replacing the spaces with underscores and making it all lowercase) <li id="this_is_a_mixed_case_string_with_spaces"><a href="#">This is a Mixed case String with SPACES</a></li>
I'd really like to understand how to accomplish this (rather than just get an answer).
thanks in advance
saul
On Sat, Mar 14, 2009 at 1:55 PM, Saul Rosenbaum saul@visualchutzpah.com wrote:
what I'm trying to accomplish is (replacing the spaces with underscores and making it all lowercase)
<li id="this_is_a_mixed_case_string_with_spaces"><a href="#">This is a Mixed case String with SPACES</a></li>
Take a look in the TextMate documentation § 7.7 "Transformations". You'll find what you're looking for there.
Alas I wish there where more basic explanation in the docsI can''t for the life of me figure it out..
On Sun, Mar 15, 2009 at 2:14 PM, Oliver Taylor olivertaylor@me.com wrote:
On Sat, Mar 14, 2009 at 1:55 PM, Saul Rosenbaum saul@visualchutzpah.com wrote:
what I'm trying to accomplish is (replacing the spaces with underscores
and
making it all lowercase)
<li id="this_is_a_mixed_case_string_with_spaces"><a href="#">This is a
Mixed
case String with SPACES</a></li>
Take a look in the TextMate documentation § 7.7 "Transformations". You'll find what you're looking for there.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
How does this work for you:
${1:type here} RESULT: ${1/(\w+)((?:_|\s)+)?/\L$1\E(?2:_)/g}
Your Code would look like: <li id="${1/(\w+)((?:_|\s)+)?/\L$1\E(?2:_)/g}"><a href="#">$1</a></li>
Breaking down the regular expression:
(\w+) = This is the first group, $1, matching a word ( (?:_|\s)+ ) = This is the second group, $2, matching multiple underscores and whitespace
Replacing with:
\L$1\E = Lowercase version of $1, the word (?2:_) = If something was found for $2, make it a single underscore
This doesn't handle non-word characters like !@#$%'" etc.
Does this point you in the right direction? - Joseph Pecoraro
On Mar 17, 2009, at 5: 12PM, Saul Rosenbaum wrote:
Alas I wish there where more basic explanation in the docs I can''t for the life of me figure it out..
On Sun, Mar 15, 2009 at 2:14 PM, Oliver Taylor olivertaylor@me.com wrote: On Sat, Mar 14, 2009 at 1:55 PM, Saul Rosenbaum <saul@visualchutzpah.com
wrote:
what I'm trying to accomplish is (replacing the spaces with
underscores and
making it all lowercase)
<li id="this_is_a_mixed_case_string_with_spaces"><a href="#">This
is a Mixed
case String with SPACES</a></li>
Take a look in the TextMate documentation § 7.7 "Transformations". You'll find what you're looking for there.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Joseph Pecoraro's message brings to mind that §20.4 of the TextMate help would also be useful.
thanks guys!
On Tue, Mar 17, 2009 at 6:21 PM, Oliver Taylor olivertaylor@me.com wrote:
Joseph Pecoraro's message brings to mind that §20.4 of the TextMate help would also be useful.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
2009/3/17 Saul Rosenbaum saul@visualchutzpah.com:
Alas I wish there where more basic explanation in the docs I can't for the life of me figure it out..
I can't remember where I got this, but it should do the trick. Been using it for ages.
<h2 id="${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}">${1:$TM_SELECTED_TEXT}</h2>
* * *
This snippet uses a placeholder:
${1:placeholder-text}
This snippet mirrors what you type in another place:
${1:Hello} #1 gets mirrored here: $1 ${2:Type something else here} and #2 gets mirrored here: $2
This snippet replaces spaces with underscores:
${1:Text with spaces} Mirrored with transformations: ${1/( )/_/g}
Hope this helps clear things up.