Home Download Buy Blog Forum Support

Regular Expressions Not Working Correctly

Regular Expressions Not Working Correctly

Postby CWSpear on Fri Mar 01, 2013 3:05 am

I have a snippet with a regular expression in it. I ported it from TextMate where it did (and does) work, but it doesn't not work in Sublime Text 2.

Here's the snippet:

Code: Select all
<?php \$${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}} = new Area("${1:Main}"); \$$2->display(\$c); ?>

When activated, it selections Main, and if I were to type something like, "Sidebar Footer," the expected outcome (and actual outcome in TextMate) is:

Code: Select all
<?php $sidebar_footer = new Area("Sidebar Footer"); $sidebar_footer->display($c); ?>

But the actual output in Sublime is:

Code: Select all
<?php $sidebar_ footer = new Area("Sidebar Footer"); $sidebar_ footer->display($c); ?>

The extra spaces shouldn't be there. I consider myself pretty good with regular expressions, but this is probably one of the extremely few times I've had to use the syntax with the search and replace in one line.

Code: Select all
Sidebar Footer/[[:alpha:]]+|( )/(?1:_:\L$0)/g
is not being evaluated correctly. I am 80ish% sure it's correct, and Sublime is wrong here, or else uses a different parser than TextMate does?

Specifically, it seems to be prepending the space with an underscore instead of replacing the space with an underscore.

Posts: 4
Joined: Fri Mar 01, 2013 2:52 am

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 13 guests