我已经使用 PDFBox 将 PDF 文档转换为文本。但是,许多单词用破折号分成 2 行。
例如,单词Others
变为Others
,单词becoming
变为be-coming
等
如果我使用 string.Replace
将“-”替换为空字符串,它会将单词之间用空格分隔开。
在C#中有没有办法去掉单词中间的破折号,把单词的各个部分重新拼接成一个单词?
最佳答案
我写了这个单元测试,破折号被正确删除了。
[TestMethod]
public void ReplaceDashByEmptyString()
{
string othersWithDash = "Oth-ers";
string othersWithoutDash = othersWithDash.Replace("-", string.Empty);
Assert.AreEqual("Others", othersWithoutDash);
}
关于c# - 如何删除使用 string.Replace ("-", ""后剩余的空间),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15800867/