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

后端 未结 14 3223
甜味超标
甜味超标 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:32

    If the language you are using supports Posix regexes, you can use them.

    An example:

    \d
    

    would be the same as

    [:digit:]
    

    The bracket notation is much clearer on what it is matching. I would still learn the "cryptic wildcard characters and symbols, since you will still see them in other people's code and need to understand them.

    There are more examples in the table on regular-expressions.info's page.

提交回复
热议问题