Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试定义一个搜索插入符号字符的正则表达式模式,但由于^用于否定,我不确定如何定义该模式。我试图让程序找到一个字符串,它是一个字母,然后是一个插入符号,然后是一个数字(您可能已经猜到,这是一个数学术语),例如"x^23". 这是我试过的线:
^
"x^23"
String caseFour = "[a-zA-Z]" + "^" + "\\d+";
它不工作。谁能帮我吗?
您还需要转义该字符,因为它是具有特殊含义的字符。
String regex = "[a-zA-Z]\\^\\d+";