正则表达式或 Java 将某些区域转换为较低的字符串
我有一段正则表达式 "([AZ]|_)*"
来查找 xml 文档中属性的大写值。我想把所有的发现都变成小写。我知道我可以使用 $
符号引用找到的组,但是如何将 $
变量的值传递到 toLowerCase()
功能。我不在乎解决方案是否涉及 java 或者简单的文本编辑器是否可以解决问题,因为这是一次性工作。
谢谢。
I have got a piece of regex "([A-Z]|_)*"
to find upper case values of attributes in a xml document. I would like to turn all the findings into lower case. I know I can reference the found group with the $
sign, but how can I pass the value of the $
variable into a toLowerCase()
function. I don't care if the solution involves java or if a simple text editor would do the trick, because it's a one time jobs.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,对于这个特定的任务,您可能应该使用 XML 解析器。话虽如此,对于正则表达式,您可以使用
Matcher
来存储捕获的组:First of all, for this particular task, you should probably use an XML parser instead. Having said that, with regular expressions, you can use a
Matcher
to store the captured groups: