Regex to *not* match any characters

前端 未结 10 1627
一个人的身影
一个人的身影 2020-12-24 11:18

I know it is quite some weird goal here but for a quick and dirty fix for one of our system we do need to not filter any input and let the corruption go into the system.

10条回答
  •  执笔经年
    2020-12-24 11:46

    Another very well supported and fast pattern that would fail to match anything that is guaranteed to be constant time:

    $unmatchable pattern $anything goes here etc.

    $ of course indicates the end-of-line. No characters could possibly go after $ so no further state transitions could possibly be made. The additional advantage are that your pattern is intuitive, self-descriptive and readable as well!

提交回复
热议问题