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. python解无忧公主数学题108

    """ python解无忧公主数学题108回文.py 题目来源: http://mp.weixin.qq.com/s?__biz=MzI5ODEwMDQyNw==& ...

  2. iOS 版本号Version和Build的区别

    一个version,一个build,都是设置版本的地方,有什么区别呢? 在ios中(Android等工程中也一样),有两种version,一种是 CFBundleVersion ("Bund ...

  3. Ogre中OctreeSceneManager

    转自:http://blog.csdn.net/yanonsoftware/article/details/1067265 既然前面分析Mesh(Entity,SceneNode)的渲染时已经看到了O ...

  4. javascript笔记1-基本概念

    关键字: 变量: function test(){ message = 'hi'; //不加var,表示全局变量:加var,表示局部变量 } 数据类型: 总共有五种基本数据类型:Undefined.N ...

  5. 转发:在开发机上绕过Chrome同源策略的办法

    在开发机上绕过Chrome同源策略的办法 标签: Chrome同源策略跨域 2013-08-21 18:33 4399人阅读 评论(0) 收藏 举报 分类: Chrome扩展(1) 版权声明:本文为博 ...

  6. Saving structured data with json

    Strings can easily be written to and read from a file. Numbers take a bit more effort, since the rea ...

  7. java作业4

    (一)  请查看String.equals()方法的实现代码,注意学习其实现方法.(发表到博客作业上) (二)  整理String类的Length().charAt(). getChars().rep ...

  8. C#指针操作Marshal实例

    static void Main(string[] args) { ,,,}; ,,,}; IntPtr pt = Marshal.AllocHGlobal(a.Length); //从source数 ...

  9. Golang Deco Enco

    mproto.go package mproto import ( "bytes" "encoding/binary" "fmt" &quo ...

  10. 阅读<构建之法>第13、14、15、16、17章 与 《一个程序员的生命周期》读后感

    第十三章   软件测试 这一章介绍了很多关于测试的方法,比如说单元测试,代码覆盖率测试,构建验证测试,验收测试等,我有一个很纠结的问题,如果我开发软件,是把这么多测试全做完,还是挑一些测试来进行呢?如 ...