Skip to content
This repository has been archived by the owner on Oct 21, 2019. It is now read-only.

String.replaceAll("*") #42

Open
hitolz opened this issue Jul 30, 2019 · 1 comment
Open

String.replaceAll("*") #42

hitolz opened this issue Jul 30, 2019 · 1 comment
Labels
tip 学习至少一个技术技巧

Comments

@hitolz
Copy link
Contributor

hitolz commented Jul 30, 2019

https://stackoverflow.com/questions/16908806/dangling-meta-character

  • 异常:Dangling meta character '*' near index 0
  • 出现场景:String.replaceAll("*")
  • 原因:*在正则表达式中有特殊含义
    String.replaceAll
    public String replaceAll(String regex, String replacement) {
        return Pattern.compile(regex).matcher(this).replaceAll(replacement);
    }

需转义

@hitolz hitolz added the tip 学习至少一个技术技巧 label Jul 30, 2019
@BLF2
Copy link

BLF2 commented Jul 31, 2019

只要携带特殊符号,一律加\\进行转义

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tip 学习至少一个技术技巧
Projects
None yet
Development

No branches or pull requests

3 participants