Regular expression for mail address
Posted: Mon Apr 02, 2007 10:12 pm
Actually, I just wanted KDE's Klipper to be able to compose a new mail when selecting any mail address instead of its default "mailto:" prefix.
So I wrote this regular expression:
...and associated it with this command (to open thunderbird):
The regexp should match most of existing mail addresses. Here's a short explanation of it:
[li](\w|-|\.) = Any word character (a-z, 0-9, _, ...) or "-" or a dot[/li]
[li]+ = at least once[/li]
[li]@ = just the "at" sign[/li]
[li](\w|-|\.)+ = again: some word character(s)[/li]
[li]\.\w{2,3} = ...followed by a dot and then 2 or 3 word characters[/li]
voila.
Now have fun selecting some text like "mymail@yourisp.com" and press "Ctrl+Alt+R" (default shortcut for Klipper's actions!"
So I wrote this regular expression:
Code: Select all
(\w|-|\.)+@(\w|-|\.)+\.\w{2,3}
Code: Select all
mozilla-thunderbird -compose to=%s
[li](\w|-|\.) = Any word character (a-z, 0-9, _, ...) or "-" or a dot[/li]
[li]+ = at least once[/li]
[li]@ = just the "at" sign[/li]
[li](\w|-|\.)+ = again: some word character(s)[/li]
[li]\.\w{2,3} = ...followed by a dot and then 2 or 3 word characters[/li]
voila.
Now have fun selecting some text like "mymail@yourisp.com" and press "Ctrl+Alt+R" (default shortcut for Klipper's actions!"