Hopstream
Hopstream

Reputation: 6451

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

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

Upvotes: 1

Views: 1685

Answers (3)

Bruno Batista
Bruno Batista

Reputation: 203

TM_FILENAME not works for windows?

Upvotes: 0

BrandonS
BrandonS

Reputation: 932

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.

Upvotes: 0

Derek Prior
Derek Prior

Reputation: 3517

Try the following snippet. Works for me.

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

Upvotes: 2

Related Questions