【发布时间】:2018-11-05 17:40:01
【问题描述】:
"\r\n\r\n\r\n\r\nCovered. Coverage is limited to a one-time only 7095 for one outpatien" +
"t in vitro fertilization procedure while you are an 7095 member. If you receive" +
" 7095s for in vitro fertilization services under an 7095 plan, you will not b" +
"e eligible for in vitro fertilization 7095s under any other 7095 plan. In vit" +
"ro fertilization services are not covered when a surrogate is used. The in vitr" +
"o procedures must be performed at a medical facility that conforms to the Americ" +
"an College of Obstetricians and Gynecologists’ guidelines for in vitro fertiliza" +
"tion clinics or to the American Society for Reproductive Medicine’s minimal stan" +
"dards for programs of in vitro fertilization. \r\n\r\n\r\n\r\n\r\nIf you have a male partn" +
"er, you must meet all of the following criteria:\r\n• You and your male partner " +
" have a five-year history of infertility or infertility is related to one or mor" +
"e of the following medical conditions: \r\n– Endometriosis; \r\n– Ex" +
"posure in utero to diethylstilbestrol (DES); \r\n– Blockage or surgical re" +
"moval of one or both fallopian tubes; or \r\n– Abnormal male factors contr" +
"ibuting to the infertility.\r\n• You and your male partner have been unable to a" +
"ttain a successful pregnancy through other covered infertility treatments.\r\n\r\n\r\n" +
"\r\n\r\nIf you do not have a male partner, you must meet the following criteria:\r\n• " +
" You are not known to be otherwise infertile, and\r\n• You have failed to achie" +
"ve pregnancy following three cycles of physician directed, appropriately timed i" +
"ntrauterine insemination.\r\n\r\n\r\n\r\n\r\nPlease note: These services must have precert" +
"ification. See Chapter 5: Precertification.\r\nPlease note: Exclusions or limits " +
"that may relate to this 7095 are described in Chapter 6: Services Not Covered" +
" in the section labeled Fertility and Infertility.\r\n\r\n\r\n\r\n"
我想将上述字符串中的 /r/n 替换为具有以下限制的空字符串。 1. 如果 /r/n 只存在一次,不要替换它(例如:/r/n) 2. 如果有多个/r/n,则替换(例如:/r/n/r/n/r/n/r/n 然后替换为空字符串。
示例字符串 "\r\n\r\n\r\n\r\n承保。承保范围仅限于\r\n 一位门诊患者的一次性 7095\r\n\r\n\r\n";
预期产出:覆盖。覆盖范围仅限于一位门诊患者的\r\n 一次性 7095
【问题讨论】:
-
使用像
"(the sequence you are looking for){2,}"这样的正则表达式并什么都不替换。 -
你能给我一个示例吗?
-
欢迎来到 StackOverflow。正如tour 中所述,此站点是有用问题及其答案的存储库,不是帮助论坛。请拨打tour,访问help center,尤其是阅读How to Ask和Why is “Can someone help me?” not an actual question?,了解如何有效使用本网站。
-
谢谢.. 解决方案对我有用
标签: java string apache-stringutils string-utils