elaine on Nostr: If you struggle writing regular expression just remember this poem it will guide you ...
If you struggle writing regular expression just remember this poem it will guide you as you write it. After memorizing this poem you will become a regex expert!
In a world where patterns swirl and twirl,
In lines of code, in digital whirl,
There exists a language, cryptic and mystic,
Regular Expressions, simple yet artistic.
To begin our tale, let's start quite small,
With dots and stars and characters all.
A dot means any, in its place,
It matches a space, or any face.
A star takes whatever comes before,
And replicates it, over and more.
It could be zero, it could be a legion,
The star's magic lies in its region.
Parentheses group, like a cozy cluster,
They unify your pattern, adding luster.
A hat for start, and dollar for end,
Their use in control, you can depend.
In brackets, your choices stand arrayed,
Only one will be the match that's made.
Use a dash to express a range,
From 'a to z', or something strange.
But, oh, the slash is a clever trickster,
Turns symbols into tools, makes patterns thicker.
\w for word, \d for a number,
Such patterns they create, enough to encumber.
A plus means one or more, no less,
Perfect for matching an address.
And then the question, a symbol coy,
Marks zero or one, like a playful toy.
But let's not forget, amidst this cheer,
The brace, our quantifier clear.
{2, 4}, says two to four,
Customized counts, who could ask for more?
The pipe, a symbol tall and straight,
Acts as an 'or' to alter fate.
A or B or maybe C,
The pipe connects, and sets them free.
At the end of our poem, as the lines grow thinner,
You're a regex champ, a real winner.
With patterns and symbols, you hold the key,
To the code's puzzle, forever free.
In a world where patterns swirl and twirl,
In lines of code, in digital whirl,
There exists a language, cryptic and mystic,
Regular Expressions, simple yet artistic.
To begin our tale, let's start quite small,
With dots and stars and characters all.
A dot means any, in its place,
It matches a space, or any face.
A star takes whatever comes before,
And replicates it, over and more.
It could be zero, it could be a legion,
The star's magic lies in its region.
Parentheses group, like a cozy cluster,
They unify your pattern, adding luster.
A hat for start, and dollar for end,
Their use in control, you can depend.
In brackets, your choices stand arrayed,
Only one will be the match that's made.
Use a dash to express a range,
From 'a to z', or something strange.
But, oh, the slash is a clever trickster,
Turns symbols into tools, makes patterns thicker.
\w for word, \d for a number,
Such patterns they create, enough to encumber.
A plus means one or more, no less,
Perfect for matching an address.
And then the question, a symbol coy,
Marks zero or one, like a playful toy.
But let's not forget, amidst this cheer,
The brace, our quantifier clear.
{2, 4}, says two to four,
Customized counts, who could ask for more?
The pipe, a symbol tall and straight,
Acts as an 'or' to alter fate.
A or B or maybe C,
The pipe connects, and sets them free.
At the end of our poem, as the lines grow thinner,
You're a regex champ, a real winner.
With patterns and symbols, you hold the key,
To the code's puzzle, forever free.