What literal characters should be escaped in a regex?

前端 未结 5 1448
予麋鹿
予麋鹿 2020-11-30 01:47

I just wrote a regex for use with the php function preg_match that contains the following part:

[\\w-.]

To match any word char

5条回答
  •  广开言路
    2020-11-30 02:28

    [\w.-]
    
    • the . usually means any character but between [] has no special meaning
    • - between [] indicates a range unless if it's escaped or either first or last character between []

提交回复
热议问题