Sublime Forum

[HELP] Sublime Regular expression snippet

#1
$person = new Person;

$person->speak();

I’m trying to create a snippet for the above piece of code, when I type $person- and hit tab I want it to expand to $person->

So I need some sort of regular expression which will match anything before the -

Is that possible?

0 Likes

#2

sounds to me like you want a keybinding and not a snippet, but if I understand right it only saves you from pressing one key? i.e. Tab instead of Shift+.

3 Likes

#3

The ? in regex means the preceding character is an optional match. So something like this may work for you:

\$p?e?r?s?o?n?-?

It should match any of the following:

$
$p
$pe
$per
$pers
$perso
$person
$person-
1 Like

#4

That’s exactly what i’m looking for, is that possible?

0 Likes