简体   繁体   English

用Java格式化字符串。 字符串->正则表达式->格式

[英]Formatting string in java. string->regex->format

I have function in java that takes 3 arguments: - String to format - regex code to fit in groups - String like "Here %s, then %s, finally %s" to fit in groups that got fitted by regex. 我在Java中具有接受3个参数的函数:-要格式化的字符串-要适合组的正则表达式代码-要像“这里是%s,然后是%s,最后是%s”的字符串适合由regex适应的组。

And here is my question. 这是我的问题。 Is there a short function in java that could reformat my string like I described here? Java中是否有一个短函数可以像我在此描述的那样重新格式化我的字符串? Or should I write my own method to do this? 还是我应该编写自己的方法来做到这一点?

Short answer: yes. 简短的回答:是的。 You can achieve this with Formatters. 您可以使用格式化程序来实现。 Just google it or take this as an initial reading. 只是谷歌它或以此作为初步阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM