Home  >  Q&A  >  body text

Java中uuid在替换中划线的时候为什么要用两个反斜线?

PHP中文网PHP中文网2741 days ago297

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:39:03

    The replacement here is to use Java’s regular expression, and Java’s regular expression is very messed up. The underscore in the regular expression must be escaped with a backslash. In Java, the backslash is a special character and must also be escaped. That’s why there are two backslashes

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:39:03

    Java replaceAll split and the like use regular expressions by default

    For solutions without escaping, please refer to my previous answer:

    https://segmentfault.com/q/10...

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:39:03

    You can do it directly, I just replaced it directly

    reply
    0
  • Cancelreply