Sublime Forum

Select whole word

#1

Hello I have a huge text which also includes email addresses.
How can I select only the emails from it?

I thought of searching all “@” signs and than selecting the whole word but I don’t know how to select the whole word command.

Thanks,
Alex

0 Likes

#2

To select a word, ctrl/cmd + D should do it.

To select an email, I would go with some regex Find All. This regex works well:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
1 Like

#3

Wow! That regexp is awesome! Thanks alot iamntz!

Where can I learn to write regexp expressions?

Have a good day,
Alex

0 Likes

#4

I can’t tell you where you can learn that kind of regex, since I had to copy from another place :smiley:

But I can suggest you where can you learn more:

  • RegexBuddy is an awesome tool that also have an extensive manual on RegExp.

Various online tools. The main advantage on RegexBuddy is that it can use more engines, while the online ones, obviously, are able only to run JS regex :slightly_smiling:

0 Likes

#5

Those are some great resources for Regex, thanks!

– np

edit

When you talk about engines. What regex engine is ST3 using for its regex?

0 Likes

#6

I’m not sure if the search regex is the same though, maybe @wbond will clarify this a bit:

0 Likes

#7

ST uses boost for the find panels.

0 Likes

#8

Which is to say that it uses a flavor of regex that contains many of the features from PCRE regexes.

The syntax highlighting uses our custom engine, but will fall back to Oniguruma when it can’t handle a construct.

1 Like