Meaning of pound (#) in a regular expression

前端 未结 3 1051
野的像风
野的像风 2021-02-19 05:59

I have a regular expression with a pound # modifier.

What does \\# mean in a regular expression? What does the # mean in a regul

3条回答
  •  悲&欢浪女
    2021-02-19 06:09

    As you have suspected, it's just a mistake.

    To be sure, I ran:

    String quote = Pattern.quote("_#_");
    

    and the output was:

    "\Q_#_\E"
    

    So, clearly, the pound symbol ("#") is not a special character for java regex.

    See: Pattern.quote()

提交回复
热议问题