txt文件中如何判断句尾是不是" "
txt文件中怎么判断句尾是不是" "?
vb.net 2003
比如说,strings.Instr 方法来可以做比较....
Public Shared Function InStr(_
Optional ByVal Start As Integer, _
ByVal String1 As String, _
ByVal String2 As String, _
) As Integer
Start
可选项。数值表达式,设置每个搜索的起始位置。如果省略该参数,则从第一个字符位置开始搜索。起始索引从一开始。
它是从起始位置开始搜索...
我想实现的是判断一行句子中的句尾是不是" ", 有什么办法像上面的方法一样能做比较...
需要详细代码以及详细说明...
------解决方案--------------------
\s$
------解决方案--------------------
"ABC " has 4 characters. "ABC ".length is 4
"ABC" has 3 characters. "ABC".length is 3.
"ABC ".rtrim() is to remove all right spaces.
sample code:
vb.net 2003
比如说,strings.Instr 方法来可以做比较....
Public Shared Function InStr(_
Optional ByVal Start As Integer, _
ByVal String1 As String, _
ByVal String2 As String, _
) As Integer
Start
可选项。数值表达式,设置每个搜索的起始位置。如果省略该参数,则从第一个字符位置开始搜索。起始索引从一开始。
它是从起始位置开始搜索...
我想实现的是判断一行句子中的句尾是不是" ", 有什么办法像上面的方法一样能做比较...
需要详细代码以及详细说明...
------解决方案--------------------
\s$
------解决方案--------------------
"ABC " has 4 characters. "ABC ".length is 4
"ABC" has 3 characters. "ABC".length is 3.
"ABC ".rtrim() is to remove all right spaces.
sample code:
- VB.NET code
Dim aString as String aString = "ABC " if aString.rtrim().length = aString.length then msgbox "The string has no space at the end." else dim numSpace as String numSpace = aString.length - aString.rtrim().length msgbox "The string has " & numSpace & " spaces at the end." end if
------解决方案--------------------
Dim re As New Regex("^.* $", RegexOptions.Multiline)
Dim oldstr As String = Read_Txt()
oldstr = Regex.Replace(oldstr, "\r\n", vbLf)
Dim match As Match = re.Match(oldstr)
match = re.Match(oldstr)
While match.Success
Console.WriteLine(match.Value)
match = match.NextMatch()
End While