Java中的原始字符串 - 特别是正则表达式 [英] Raw Strings in Java - for regex in particular

查看:260
本文介绍了Java中的原始字符串 - 特别是正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Java中使用原始字符串(没有转义序列)?

Is there any way to use raw strings in Java (without escape sequences)?

(我正在写相当数量的正则表达式代码和原始字符串会使我的代码更具可读性)

(I'm writing a fair amount of regex code and raw strings would make my code immensely more readable)

我知道该语言不能直接提供,但是有什么方法可以用任何方式模拟它们吗?

I understand that the language does not provide this directly, but is there any way to "simulate" them in any way whatsoever?

推荐答案

不,没有。

一般来说,你会把原始的属性文件中的字符串和正则表达式,但那些也有一些转义序列要求。

Generally, you would put raw strings and regexes in a properties file, but those have some escape sequence requirements too.

这篇关于Java中的原始字符串 - 特别是正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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