I think that I miss something mysterious about .

I know them well, I use them often and yet, when I think about WHY they are so powerful and effective while being so cryptic, I cannot find a rigorous answer.

I've explained them to people several times, but I was never happy with the explanation itself: it was effective for the people involved but listening to myself I was all "how can somebody understand what I mean by listening what I say?"

Now when you cannot explain a subject clearly, you ALWAYS know that you do not understand it.

But HOW CAN regular expression be so effective and still so cryptic? Why we can't have readable regular expression? (and we can't)

What am I missing?

Follow

@Shamar Interesting question. Amateur guess on my part:

Regexes are used for matching strings of characters, which are themselves pretty compact. So the more verbose your pattern-matching language is, the less it looks like the string you're trying to match.

For example, matching commonwealth and American spellings of a word:
Regex: "[Ff]avou?rite"
Verbose description:
[character('f', ignore-case),\
substring("avo"),\
character('u', optional),\
substring("rite")]

If you don't know regex syntax, the second one probably seems less cryptic, but once you get the hang of it, it's easier to quickly recognise what the first one's doing.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.