The main objective of this project is to help you understand regular expressions in a relaxed way, with clear examples and practical approaches, accompanied by a shot of whiskey or similar, but you can follow with gin and tonic as well.
Metacharacter | Name | Characteristic | Function |
---|---|---|---|
. |
Dot | Represent | Any character |
[] |
List | Represent | List of allowed characters |
[^] |
Denied list | Represent | List of prohibited characters |
? |
Optional | Quantify | Zero or one |
* |
Asterisk | Quantify | Zero, one or more |
+ |
Plus | Quantify | One or more |
{} |
Curly brackets | Quantify | From one value to another |
^ |
Circumflexus | Anchor | Start of line |
$ |
Dollar sign | Anchor | End of line |
\b |
Border | Anchor | Beginning or end of word |
\ |
Escape | Other | Make something literal |
| |
Or | Other | Or one or the other |
() |
Group | Other | Delimits a group |
\1 |
Rearview | Other | Text married in a certain group |
The dot is a wildcard character that matches anything, including itself.
/whisk.y/
With its traditional combination of rye whiskey, sweet vermouth, and bitters, the Manhattan is an icon in the whisk*y world. It is to whiskey what the martini is to gin and the base for countless cocktails. You can make it with bourbon, Canadian whisky, or any other style, and it's a splendid recipe to use when trying out any new-to-you brand of whisk.y.
/9.m/
9pm is a good time to drink whiskey, but it's not a good time to drink coffee, in which case 9am would be a more appropriate time. 9pm can also be a good time for a cup of tea if you've already exceeded your daily whiskey quota.
/ca./
It is not recommended to drive a car if you drink a shot of whiskey, or any other alcoholic beverage. Maybe it's better to enjoy your cat's company or prepare a new shot.
The list matches who she knows and has its own rules and within it everyone is normal, but the dash (-
) indicates range and should be the last item on the list.
/co[ckl][ea]/i
As the drink’s name implies, its two components are Coca-Cola or any cola of your choice (though Coke’s relatively high acidity renders it a particularly good match against the liquor), plus any whiskey, though Jack Daniel’s seems to be by far the most popular option—which is then called, yes, a Jack & Coke or even a Lemmy, for the Motörhead frontman notoriously fond of the drink.
/ex[tp]ensive/
Whiskey is an extensive drink for the trade, but the import price can get expensive, especially for some palates.
/co[ua]rse/
Is the texture of the jacket you are wearing smooth or coarse? Anyway, it goes great with your drink, of course.
This project is licensed under the MIT License.