TextMate Snippet: How to uppercase the first letter in a regexp

1.6k views Asked by At

How can I make the first letter upper case in the following:

${1:${TM_FILENAME/[\.php]+$//}}

Basically if the filename is "welcome.php", I'd like it to write out "Welcome". This at the moment writes "welcome" (lower case w).

3

There are 3 answers

0
Derek Prior On BEST ANSWER

Try the following snippet. Works for me.

${TM_FILENAME/(.*?)(\..+)/\u$1/}
0
BrandonS On

For some reason the above example gives you weird charectors when using it ... it took me a while but the solution below works if you are still looking. It has two solutions here for you the first one is for actual textmate on mac:

${TM_FILENAME/(^.)(.*?)(\.php)/(?1:\U$1)(?2:)(?3:)/}

The next is if you are using e Texteditor on PC:

${TM_FILENAME/(^.)(.*?)(\.php)/(?1:)(?2:$2)(?3:)/}

I hope this helps you if you haven't already.

0
Bruno Batista On

TM_FILENAME not works for windows?