[TxMt] Snippet regex transformation help

Ed Singleton singletoned at gmail.com
Thu Oct 5 14:38:54 UTC 2006


I'm trying to use a regex transformation in a snippet that will
convert the first letter of a word to uppercase and convert underscore
_ followed by a letter to a space and an uppercase letter.

eg:

field_name > Field Name
long_field_name > Long Field Name

I can't quite get get my head round how to do it, as it seems like two
seperate transformations, but I'm not sure how to to do
transformations on a string in a snippet.

Is there a collection of regexes for transforming between the main
cases? (particularly Camel, Title and underscore seperated)  I managed
one that went from CamelCase to underscore_seperated:

${1/([a-z0-9])?([A-Z])/(?1:$1_)\l$2/g}

Thanks

Ed



More information about the textmate mailing list