Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 [ ^

出现此错误应该是字符转义出现问题:

System.out.println(str.replaceAll("[", "22"));
解决方案:在[之前加上\\
System.out.println(str.replaceAll("\\[", "22"));

随机推荐

  1. IOS多线程之NSOperation学习总结

    NSOperation简介 1.NSOperation的作用 配合使用NSOperation和NSOperationQueue也能实现多线程编程 2.NSOperation和NSOperationQu ...

  2. Cocoa Drawing

    Graphics Contexts Graphics contexts are a fundamental part of the drawing infrastructure in Cocoa ap ...

  3. About View

    View Geometry Frame & Bounds Graphically, a view can be regarded as a framed canvas. The frame l ...

  4. Java基础毕向东day02

    1. 常量 null 等特殊 2.标识符 数字-字母-下划线,数字不能开头 3.二进制 1> 二进制计算方法. 2>常用二进制. 1        1      0       0   1 ...

  5. iOS 三种录制视频方式

    随着每一代 iPhone 处理能力和相机硬件配置的提高,使用它来捕获视频也变得更加有意思.它们小巧,轻便,低调,而且与专业摄像机之间的差距已经变得非常小,小到在某些情况下,iPhone 可以真正替代它 ...

  6. libbspatch.so

    http://www.zhihu.com/question/21154099 http://blog.csdn.net/hmg25/article/details/8100896 91助手和Googl ...

  7. hdoj-2019

    #include "stdio.h"void sort(int number[],int n,int m);int main(){ int n,m,i,number[100]; s ...

  8. 【LeetCode OJ】Best Time to Buy and Sell Stock III

    Problem Link: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ Linear Time Solut ...

  9. C# Socket Server 收不到数据

    #/usr/bin/env python # -*- coding: utf- -*- # C# Socket Server 收不到数据 # 说明: # 最近在调Python通过Socket Clie ...

  10. 即使连网了ping也会失败

    /*************************************************************************** * 即使连网了ping也会失败 * 说明: * ...