`

Dangling meta character '?' near index 0

 
阅读更多

Problem

String str = "testing??"; 

str = str.replaceAll("?", ""); 

When you use the above pattern you get an exception as "Dangling meta character '?' near index 0" 


Solution 

String str = "testing??"; 

str = str.replaceAll("//?", ""); 

You can use the above solution when you are replacing * and + symbols 

String str = "testing??*+"; 

str = str.replaceAll("//*", ""); //"Dangling meta character '*' near index 0" 
str = str.replaceAll("//+", ""); //"Dangling meta character '+' near index 0"

 

+、*、|、/等符号在正则表达示中有相应的不同意义。
一般来讲只需要加[]、或是//即可

int i=s.split("[?]").length;

或者

int i=s.split("//?").length;i);

分享到:
评论

相关推荐

    dangling-pointer-rampage-master.rar

    dangling-pointer-rampage-master.rar

    Docker 清理环境操作

    docker volume ls -qf dangling=true 清理无用的卷 docker volume rm $(docker volume ls -qf dangling=true) 清理无用的镜像 docker rmi $(docker images | grep ‘^’ | awk ‘{print $3}’) 继续清理 ...

    dangling-pointer-rampage:为学习目的而开发的Rust游戏

    悬空指针猛冲 为学习目的而开发的Rust游戏。 货物监视-x run --clear

    你可能不知道的docker命令奇淫怪巧

    build 自己的 docker 镜像的时候,有时会遇到用一个甚至多个中间层镜像,这会一定程度上减少最终打包出来 docker 镜像的大小,但是会产生一些tag 为 none 的无用镜像,也称为悬挂镜像 (dangling images) 列出所有的 ...

    OSGI in Action

    brief contents PART 1 INTRODUCING OSGI: MODULARITY, LIFECYCLE, AND SERVICES 1 1 ■ OSGi revealed 3 2 ■ Mastering modularity 24 3 ■ Learning lifecycle 69 4 ■ Studying services 117 ...index 531

    docker-cleanup:删除过时的Docker容器和映像

    docker-cleanup:删除过时的 Docker 容器和镜像 docker-cleanup 根据配置文件中的规则...# Delete dangling (unnamed and not used by containers) images. DELETE IMAGE IF Image.Dangling; 这会产生输出: Deleting

    Docker 清理命令集锦

     删除所有未打 dangling 标签的镜像 代码如下:docker rmi $(docker images -q -f dangling=true)  删除所有镜像 代码如下:docker rmi $(docker images -q)  为这些命令创建别名 代码如下:# ~/.bash_aliases # ...

    Docker常用的清除容器镜像命令小结

    前言 Docker 是一个非常有趣的项目。它自己宣称可以减轻部署服务器的难度,当然我相信里面有炒作的...删除所有\’untagged/dangling\’ ()状态的镜像 docker rmi $(docker images -q -f dangling=true) 删除所有镜像

    VirtualTreeView.v.6.3.0.XE3-XE10.1

    * Fixed #602: Dangling WM_Timer and doubled OnChange calls * Fixed #606: High DPI Inheritance of Form. TBaseVirtualTree.ChangeScale() now respects inherited property ScalingFlags * Fixed #608: ...

    VirtualTreeView.v.6.3.0.XE3-XE10.1.Src

    * Fixed #602: Dangling WM_Timer and doubled OnChange calls * Fixed #606: High DPI Inheritance of Form. TBaseVirtualTree.ChangeScale() now respects inherited property ScalingFlags * Fixed #608: ...

    programing rust release 版

    You’ll learn how Rust offers the rare and valuable combination of statically verified memory safety and low-level control—imagine C++, but without dangling pointers, null pointer dereferences, ...

    Git Recipes

    How to deal with issues like dangling revisions and disjointed branches How to pinpoint who made specific changes How to deal with textual and binary conflicts How to work with hosted solutions like ...

    Programming Rust Fast, Safe Systems Development

    Rust’s modern, flexible types ensure your program is free of null pointer dereferences, double frees, dangling pointers, and similar bugs, all at compile time, without runtime overhead. In multi-...

    aiof-portal:多合一财务前端用户界面

    概述 Aiof门户 文献资料 所有文件 图书馆 React 添加自定义环境变量 额外细节 ...docker rmi $ (docker images -f “ dangling=true ” - q) Docker撰写 从项目根目录 docker - compose up 从上面运行np

    Allegro ,skill

    PCB初始参数设置、对齐器件或VIA等、移动器件到格点上、切割CLINE、更改...Dangling Cline Via检查、跨切割线辅助检查、自动添加光绘层面、钻孔批处理工具、绘制BMP图像、将SHAPE轮廓转换成线段、缩放SHAPE尺寸、切割...

    Programming Rust

    You’ll learn how Rust offers the rare and valuable combination of statically verified memory safety and low-level control—imagine C++, but without dangling pointers, null pointer dereferences, ...

    表面悬挂键导致硅纳米线掺杂失效机理的第一性原理研究

    能带结构分析表明,B/N掺杂的H钝化的SiNWs表现出正常的p/n特性,而表面悬挂键(dangling binding,DB)的存在会导致P型(B原子)或者n型(N原子)掺杂失效;其失效的原因主要是因为表面悬挂键所引入的缺陷能级俘获了n型杂质(p...

    docker 服务器配置

    可以用于清理磁盘,删除关闭的容器、无用的数据卷和网络,以及dangling镜像(即无tag的镜像) docker system prune -a 清理得更加彻底,可以将没有容器使用Docker镜像都删掉。注意,这两个命令会把你暂时关闭的容器,...

    express-react-isomorphic

    Express React 同构 用于运行 React 的启动项目。 应用 期望 mongodb、redis 和 petecoop/nginx-proxy 已经在运行。 居住 docker-compose -f docker-... docker rmi $(docker images -f "dangling=true" -q)

    QMK-Configurator:QMK的通用配置器,旨在通过GUI支持QMK能够提供的所有功能

    QMK配置器QMK的通用配置器,旨在通过GUI支持QMK能够提供的所有功能运行应用程序安装Docker 在根目录下运行docker ... docker rm $(docker ps -q -f 'status=exited')docker rmi $(docker images -q -f "dangling=true")

Global site tag (gtag.js) - Google Analytics