如何编写正则表达式来满足这些要求?我只能使用 string.replaceAll 函数..
a) For ”
which 出现在段落末尾有一个“
, 但不是“ “
-remove”
b)对于“
出现在段落开头的内容删除 “
[注意:如果有“ “
,现在应该是“
]
c)对于”
出现在段落末尾而在段落“
开头没有匹配的内容 - 删除”
编辑:
Rule a)
Transform:
String input1 ="“remove quotes”"
String output1 ="“remove quotes"
Don't change anything:
String input1 ="““remove quotes”"
String output1 ="““remove quotes”"
Rule b)
Transform:
String input1 ="“remove quotes”"
String output1 ="remove quotes”"
Replace with single ldquo:
String input1 ="““remove quotes”"
String output1 ="“remove quotes”"
Rule c)
Do nothing (there is a matching ldquo):
String input1 ="“do not remove quotes”"
String output1 ="“do not remove quotes”"
Transform(no matching ldquo hence remove rdquo):
String input1 ="remove quotes”"
String output1 ="remove quotes"
I think I am going to run all the 3 rules separately on the string. What would be 3 regexes and replace expressions ?