Why can't Regular Expressions use keywords instead of characters?

后端 未结 14 3146
甜味超标
甜味超标 2021-02-20 06:46

Okay, I barely understand RegEx basics, but why couldn\'t they design it to use keywords (like SQL) instead of some cryptic wildcard characters and symbols?

Is it for pe

14条回答
  •  攒了一身酷
    2021-02-20 07:08

    It's Perl's fault...!

    Actually, more specifically, Regular Expressions come from early Unix development, and concise syntax was a lot more highly valued then. Storage, processing time, physical terminals, etc were all very limited, rather unlike today.

    The history of Regular Expressions on Wikipedia explains more.

    There are alternatives to Regex, but I'm not sure any have really caught on.

    EDIT: Corrected by John Saunders: Regular Expressions were popularised by Unix, but first implemented by the QED editor. The same design constraints applied, even more so, to earlier systems.

提交回复
热议问题