文本框问题的句子案例

时间:2014-10-10 02:46:15

标签: vb.net

因此,下面的代码基本上将文本框中的任何内容转换为句子格式。虽然,它并没有把这封信和#34;我的任何帮助都用于此?感谢

Public Shared Function SentenceCase(ByVal Input As String) As String
        Dim SentenceBreakers As String = System.Text.RegularExpressions.Regex.Escape(".!?" & vbCrLf)
        Dim Pattern As String = "((?<=^[^" & SentenceBreakers & "\w]{0,})[a-z]|(?<![" & SentenceBreakers & "])(?<=[" & SentenceBreakers & "][^" & SentenceBreakers & "\w]{0,})[a-z])"
        Return System.Text.RegularExpressions.Regex.Replace(Input, Pattern, Function(m) m.Value(0).ToString().ToUpper() & m.Value.Substring(1))
    End Function

1 个答案:

答案 0 :(得分:0)

您可以尝试在结尾添加一个.Replace(&#34; i&#34;,&#34; I&#34;)

Return System.Text.RegularExpressions.Regex.Replace(Input, Pattern, Function(m) m.Value(0).ToString().ToUpper() & m.Value.Substring(1)).Replace(" i "," I ")