updates regex md and adds demo files

This commit is contained in:
waldek 2021-07-06 22:50:37 +02:00
parent 10a5c587a7
commit 6bfbb8e937
5 changed files with 103079 additions and 1 deletions

View File

@ -0,0 +1,5 @@
Hey there where ya goin, not exactly knowin, who says you have to call just one place home. Hes goin everywhere, B.J. McKay and his best friend Bear. He just keeps on movin, ladies keep improvin, every day is better than the last. New dreams and better scenes, and best of all I dont pay property tax. Rollin down to Dallas, whos providin my palace, off to New Orleans or who knows where. Places new and ladies, too, Im B.J. McKay and this is my best friend Bear.
Ulysses, Ulysses — Soaring through all the galaxies. In search of Earth, flying in to the night. Ulysses, Ulysses — Fighting evil and tyranny, with all his power, and with all of his might. Ulysses — no-one else can do the things you do. Ulysses — like a bolt of thunder from the blue. Ulysses — always fighting all the evil forces bringing peace and justice to all.
Hong Kong Phooey, number one super guy. Hong Kong Phooey, quicker than the human eye. Hes got style, a groovy style, and a car that just wont stop. When the going gets tough, hes really rough, with a Hong Kong Phooey chop (Hi-Ya!). Hong Kong Phooey, number one super guy. Hong Kong Phooey, quicker than the human eye. Hong Kong Phooey, hes fan-riffic!

View File

@ -0,0 +1,5 @@
* I'm a list
* I'm a second item in the list
* and a third one
* me, a 4th one

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,594 @@
Aardvark
Abyssinian
Adelie Penguin
Affenpinscher
Afghan Hound
African Bush Elephant
African Civet
African Clawed Frog
African Forest Elephant
African Palm Civet
African Penguin
African Tree Toad
African Wild Dog
Ainu Dog
Airedale Terrier
Akbash
Akita
Alaskan Malamute
Albatross
Aldabra Giant Tortoise
Alligator
Alpine Dachsbracke
American Bulldog
American Cocker Spaniel
American Coonhound
American Eskimo Dog
American Foxhound
American Pit Bull Terrier
American Staffordshire Terrier
American Water Spaniel
Anatolian Shepherd Dog
Angelfish
Ant
Anteater
Antelope
Appenzeller Dog
Arctic Fox
Arctic Hare
Arctic Wolf
Armadillo
Asian Elephant
Asian Giant Hornet
Asian Palm Civet
Asiatic Black Bear
Australian Cattle Dog
Australian Kelpie Dog
Australian Mist
Australian Shepherd
Australian Terrier
Avocet
Axolotl
Aye Aye
Baboon
Bactrian Camel
Badger
Balinese
Banded Palm Civet
Bandicoot
Barb
Barn Owl
Barnacle
Barracuda
Basenji Dog
Basking Shark
Basset Hound
Bat
Bavarian Mountain Hound
Beagle
Bear
Bearded Collie
Bearded Dragon
Beaver
Bedlington Terrier
Beetle
Bengal Tiger
Bernese Mountain Dog
Bichon Frise
Binturong
Bird
Birds Of Paradise
Birman
Bison
Black Bear
Black Rhinoceros
Black Russian Terrier
Black Widow Spider
Bloodhound
Blue Lacy Dog
Blue Whale
Bluetick Coonhound
Bobcat
Bolognese Dog
Bombay
Bongo
Bonobo
Booby
Border Collie
Border Terrier
Bornean Orang-utan
Borneo Elephant
Boston Terrier
Bottle Nosed Dolphin
Boxer Dog
Boykin Spaniel
Brazilian Terrier
Brown Bear
Budgerigar
Buffalo
Bull Mastiff
Bull Shark
Bull Terrier
Bulldog
Bullfrog
Bumble Bee
Burmese
Burrowing Frog
Butterfly
Butterfly Fish
Caiman
Caiman Lizard
Cairn Terrier
Camel
Canaan Dog
Capybara
Caracal
Carolina Dog
Cassowary
Cat
Caterpillar
Catfish
Cavalier King Charles Spaniel
Centipede
Cesky Fousek
Chameleon
Chamois
Cheetah
Chesapeake Bay Retriever
Chicken
Chihuahua
Chimpanzee
Chinchilla
Chinese Crested Dog
Chinook
Chinstrap Penguin
Chipmunk
Chow Chow
Cichlid
Clouded Leopard
Clown Fish
Clumber Spaniel
Coati
Cockroach
Collared Peccary
Collie
Common Buzzard
Common Frog
Common Loon
Common Toad
Coral
Cottontop Tamarin
Cougar
Cow
Coyote
Crab
Crab-Eating Macaque
Crane
Crested Penguin
Crocodile
Cross River Gorilla
Curly Coated Retriever
Cuscus
Cuttlefish
Dachshund
Dalmatian
Darwin's Frog
Deer
Desert Tortoise
Deutsche Bracke
Dhole
Dingo
Discus
Doberman Pinscher
Dodo
Dog
Dogo Argentino
Dogue De Bordeaux
Dolphin
Donkey
Dormouse
Dragonfly
Drever
Duck
Dugong
Dunker
Dusky Dolphin
Dwarf Crocodile
Eagle
Earwig
Eastern Gorilla
Eastern Lowland Gorilla
Echidna
Edible Frog
Egyptian Mau
Electric Eel
Elephant
Elephant Seal
Elephant Shrew
Emperor Penguin
Emperor Tamarin
Emu
English Cocker Spaniel
English Shepherd
English Springer Spaniel
Entlebucher Mountain Dog
Epagneul Pont Audemer
Eskimo Dog
Estrela Mountain Dog
Falcon
Fennec Fox
Ferret
Field Spaniel
Fin Whale
Finnish Spitz
Fire-Bellied Toad
Fish
Fishing Cat
Flamingo
Flat Coat Retriever
Flounder
Fly
Flying Squirrel
Fossa
Fox
Fox Terrier
French Bulldog
Frigatebird
Frilled Lizard
Frog
Fur Seal
Galapagos Penguin
Galapagos Tortoise
Gar
Gecko
Gentoo Penguin
Geoffroys Tamarin
Gerbil
German Pinscher
German Shepherd
Gharial
Giant African Land Snail
Giant Clam
Giant Panda Bear
Giant Schnauzer
Gibbon
Gila Monster
Giraffe
Glass Lizard
Glow Worm
Goat
Golden Lion Tamarin
Golden Oriole
Golden Retriever
Goose
Gopher
Gorilla
Grasshopper
Great Dane
Great White Shark
Greater Swiss Mountain Dog
Green Bee-Eater
Greenland Dog
Grey Mouse Lemur
Grey Reef Shark
Grey Seal
Greyhound
Grizzly Bear
Grouse
Guinea Fowl
Guinea Pig
Guppy
Hammerhead Shark
Hamster
Hare
Harrier
Havanese
Hedgehog
Hercules Beetle
Hermit Crab
Heron
Highland Cattle
Himalayan
Hippopotamus
Honey Bee
Horn Shark
Horned Frog
Horse
Horseshoe Crab
Howler Monkey
Human
Humboldt Penguin
Hummingbird
Humpback Whale
Hyena
Ibis
Ibizan Hound
Iguana
Impala
Indian Elephant
Indian Palm Squirrel
Indian Rhinoceros
Indian Star Tortoise
Indochinese Tiger
Indri
Insect
Irish Setter
Irish WolfHound
Jack Russel
Jackal
Jaguar
Japanese Chin
Japanese Macaque
Javan Rhinoceros
Javanese
Jellyfish
Kakapo
Kangaroo
Keel Billed Toucan
Killer Whale
King Crab
King Penguin
Kingfisher
Kiwi
Koala
Komodo Dragon
Kudu
Labradoodle
Labrador Retriever
Ladybird
Leaf-Tailed Gecko
Lemming
Lemur
Leopard
Leopard Cat
Leopard Seal
Leopard Tortoise
Liger
Lion
Lionfish
Little Penguin
Lizard
Llama
Lobster
Long-Eared Owl
Lynx
Macaroni Penguin
Macaw
Magellanic Penguin
Magpie
Maine Coon
Malayan Civet
Malayan Tiger
Maltese
Manatee
Mandrill
Manta Ray
Marine Toad
Markhor
Marsh Frog
Masked Palm Civet
Mastiff
Mayfly
Meerkat
Millipede
Minke Whale
Mole
Molly
Mongoose
Mongrel
Monitor Lizard
Monkey
Monte Iberia Eleuth
Moorhen
Moose
Moray Eel
Moth
Mountain Gorilla
Mountain Lion
Mouse
Mule
Neanderthal
Neapolitan Mastiff
Newfoundland
Newt
Nightingale
Norfolk Terrier
Norwegian Forest
Numbat
Nurse Shark
Ocelot
Octopus
Okapi
Old English Sheepdog
Olm
Opossum
Orang-utan
Ostrich
Otter
Oyster
Pademelon
Panther
Parrot
Patas Monkey
Peacock
Pekingese
Pelican
Penguin
Persian
Pheasant
Pied Tamarin
Pig
Pika
Pike
Pink Fairy Armadillo
Piranha
Platypus
Pointer
Poison Dart Frog
Polar Bear
Pond Skater
Poodle
Pool Frog
Porcupine
Possum
Prawn
Proboscis Monkey
Puffer Fish
Puffin
Pug
Puma
Purple Emperor
Puss Moth
Pygmy Hippopotamus
Pygmy Marmoset
Quail
Quetzal
Quokka
Quoll
Rabbit
Raccoon
Raccoon Dog
Radiated Tortoise
Ragdoll
Rat
Rattlesnake
Red Knee Tarantula
Red Panda
Red Wolf
Red-handed Tamarin
Reindeer
Rhinoceros
River Dolphin
River Turtle
Robin
Rock Hyrax
Rockhopper Penguin
Roseate Spoonbill
Rottweiler
Royal Penguin
Russian Blue
Sabre-Toothed Tiger
Saint Bernard
Salamander
Sand Lizard
Saola
Scorpion
Scorpion Fish
Sea Dragon
Sea Lion
Sea Otter
Sea Slug
Sea Squirt
Sea Turtle
Sea Urchin
Seahorse
Seal
Serval
Sheep
Shih Tzu
Shrimp
Siamese
Siamese Fighting Fish
Siberian
Siberian Husky
Siberian Tiger
Silver Dollar
Skunk
Sloth
Slow Worm
Snail
Snake
Snapping Turtle
Snowshoe
Snowy Owl
Somali
South China Tiger
Spadefoot Toad
Sparrow
Spectacled Bear
Sperm Whale
Spider Monkey
Spiny Dogfish
Sponge
Squid
Squirrel
Squirrel Monkey
Sri Lankan Elephant
Staffordshire Bull Terrier
Stag Beetle
Starfish
Stellers Sea Cow
Stick Insect
Stingray
Stoat
Striped Rocket Frog
Sumatran Elephant
Sumatran Orang-utan
Sumatran Rhinoceros
Sumatran Tiger
Sun Bear
Swan
Tang
Tapanuli Orang-utan
Tapir
Tarsier
Tasmanian Devil
Tawny Owl
Termite
Tetra
Thorny Devil
Tibetan Mastiff
Tiffany
Tiger
Tiger Salamander
Tiger Shark
Tortoise
Toucan
Tree Frog
Tropicbird
Tuatara
Turkey
Turkish Angora
Uakari
Uguisu
Umbrellabird
Vampire Bat
Vervet Monkey
Vulture
Wallaby
Walrus
Warthog
Wasp
Water Buffalo
Water Dragon
Water Vole
Weasel
Welsh Corgi
West Highland Terrier
Western Gorilla
Western Lowland Gorilla
Whale Shark
Whippet
White Faced Capuchin
White Rhinoceros
White Tiger
Wild Boar
Wildebeest
Wolf
Wolverine
Wombat
Woodlouse
Woodpecker
Woolly Mammoth
Woolly Monkey
Wrasse
X-Ray Tetra
Yak
Yellow-Eyed Penguin
Yorkshire Terrier
Zebra
Zebra Shark
Zebu
Zonkey
Zorse

View File

@ -41,6 +41,79 @@ One of the advantages of perl regexes is reverse matching.
## The basics
### Fundamental structure and anchoring
Download the following [file](./assets/regex_03.txt) which is an American English dictionary we will use to test out some basic patterns.
Fire up a terminal and find all words that contain the string `abba`.
You already know how to do this with `grep`, nothing really special here.
`grep 'abba' regex_03.txt` should give give you a list containing 16 words.
Notice the color output in you terminal.
What if we only want the words containing `abba` but who *also* start with `s`?
This can be done with the following line `grep 's.*abba' regex_03.txt`.
You should have 6 matches left.
How about the same ones, but they have to end with an `s`?
You guessed it, `grep 's.*abba.*s' regex_03.txt`, get's the job done.
Now, what are those special characters?
They are *like* [wildcards in bash](https://ryanstutorials.net/linuxtutorial/wildcards.php) but on steroids.
In the example above, the `.` represents almost any character, and the `*` means as **many** times as we want.
They are both very powerful, and broad, matching patterns that are part of the [fundamental structure](https://www.gnu.org/software/grep/manual/html_node/Fundamental-Structure.html#Fundamental-Structure) of regex.
They work well but sometime we need to be a bit more precise, which we'll get to in a bit.
Second little example with the same list.
What if we want all words with the letter `a` in them?
Easy, `grep 'a' regex_03.txt` should do the trick but 52849 results are a bit much.
Let's trim it back to only the words having `aa` in them?
`grep 'aa' regex_03.txt` brings it down to 65 matches.
Nice.
Now, how about only the ones that *start* with `aa`?
This can be done with an other core concept of regex called [anchoring](https://www.gnu.org/software/grep/manual/html_node/Anchoring.html#Anchoring) and can be done as such `grep '^aa' regex_03.txt`.
Here the `^` signifies the **start** of the line.
Last one, I promise, what if we want of those three only the ones with `s` at the end?
Right, `grep '^aa.*s$' regex_03.txt` should do the trick where `$` means **ends** with.
### Character classes and bracket expansion
Let's find, in the following [file](./assets/regex_04.txt) all words starting with a capital case letter.
This can be done in multiple ways.
First we try one you *should* remember from your bandit days.
Does `[a-zA-Z]` ring a bell?
You used it to do ROT13 rotation somewhere around level 12.
`grep '^[A-Z].*' regex_04.txt` greps out all words starting with a capital.
Wonderful, but a bit too many words.
Let's limit it to only words that have punctuation in them.
This, `grep '^[A-Z][[:alnum:]]*[[:punct:]].*' regex_04.txt`, which is *very* cryptic does the job.
Let's break it down a bit:
* `^[A-Z]` matches all capital letters
* `[[:alnum:]]*` all letters and number, as many times as we want
* `[[:punct:]]` matches any punctuation, but just **once**
* `.*` matches almost any character as many times as we want
In the above pattern you see *two* different forms of character classes, the `[A-Z]` and the `[[:alnum:]]`.
Worth noting is that you can negate an expansion by putting a `^` inside it as such `grep '^[^A-Z].*' regex_03.txt` (not I used the first list because the animals list has no words starting with a capital letter).
This is basically the same as `grep '^[a-z].*' regex_03.txt`.
### The backslash character and special expressions
If we want to match only animals that contain multiple words we can use [special expressions](https://www.gnu.org/software/grep/manual/html_node/The-Backslash-Character-and-Special-Expressions.html#The-Backslash-Character-and-Special-Expressions).
Have a look at the output of this grep pattern `grep '\s[[:alpha:]]*' regex_04.txt`.
Here we notice we can select only parts of the lines too!
A handy flag we can add to the `grep` command is `-o` which will only print the part that matches (in red).
If we only want single words coming out of the search we can do this like so `grep -o '\s[a-zA-Z]*\>' regex_04.txt`.
Notice how it starts with an empty space?
let's break this one down.
* `\s` matches whitespace
* `[a-zA-Z]*` matches the entire alphabet as many times as we want
* `\>` matches the end of the word (not really needed here)
## Beyond basic
TODO
## Exercises
@ -49,7 +122,7 @@ Below are some practical exercises and files to go with them.
Use them to test out you grepping skills and as inspiration for personal challenges.
* configuration [file](./assets/sysctl.conf)
* print only lines with actual configuration settings (ignore comments)
* print only lines with actual configuration settings (ignore comments and empty lines)
* css [file](./assets/teddit.css)
* extract all the hex color codes
* html [file](./assets/teddit.html)