I need two different regex. The first one is to match the last two digits of a year, for instance if I have "2010" I would like to obtain "10". I tried doing something like
\d{2}\Z
but it didn't work. The second one is two obtain the first three letters of various names and surnames separated by "and". For instance I have
John Smith and Paul Anthony Doe
I would like a regex that returns "SmiDoe" but only "Smi" if Doe is not present. It would be nice it works also with more that just two names and surnames.
Edit: The provided solutions work perfectly, and now I'm trying to use them to build bibtex (.bib extension) snippets using Ultisnips plugin for Vim. The snippet I tried is
snippet ta "Test" b
@Article{${1/\s(\w{,3})\w*($|\sand)/$1/g}${2/\d{2}$/$0/g},
author={${1:John Smith and Paul Anthony Samuelson}}
year={${2:2010}}}
endsnippet
The problem is that when the snippet is expanded I get "JohnSmi Paul AnthonySam2010" and I would like to obtain "SmiSam10".