String.matches()的DOTALL [英] DOTALL for String.matches()

查看:108
本文介绍了String.matches()的DOTALL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道DOTALL可用于完全成熟的Pattern + Matcher类。

I know that DOTALL is available for the fully fledged Pattern+Matcher classes.

但如果我只想使用 String.matches(),有没有办法告诉它使用DOTALL修饰符?

But if I want to only use String.matches(), is there a way to tell it to use the DOTALL modifier?

推荐答案

您可以使用嵌入式标志(?s)启用它,如

You can enable it with the embedded flag (?s), as in

"\n".matches("(?s)."); // true

这是Javadoc

这篇关于String.matches()的DOTALL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆