0
"\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\nCovered。覆盖范围仅限于\r\n 一位门诊患者的一次性 7095\r\n\r\n\r\n” ;

预期产出:涵盖。一位门诊患者的承保范围仅限于\r\n 一次性 7095

4

1 回答 1

0

我会写这样的东西:

my_str = my_str.replaceAll("(\r\n){2,}", "");

希望有帮助。

于 2018-11-05T17:59:33.280 回答