vb.net 中的字符串搜索、查找功能在哪里
答案:1 悬赏:0 手机版
解决时间 2021-02-13 09:24
- 提问者网友:咪咪
- 2021-02-12 22:40
在VB中,打开一个文本文件或者二进制文件,就是找不到类似WORD的查找 搜索功能,这个查找搜索到底怎样实现的,通过语句当然也可以,但是在VB中难道就没有现成的查找语句或者函数吗,求解
最佳答案
- 五星知识达人网友:掌灯师
- 2021-02-13 00:06
有啊,用正则表达式,下面是简单的例子
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = "ABCDAEAFAG"
Dim Patter As String = "A"
Dim Matches As MatchCollection = Regex.Matches(str, Patter, RegexOptions.IgnoreCase Or RegexOptions.ExplicitCapture)
For Each ws In Matches
ListBox1.Items.Add("索引位置:" & ws.index)
Next
End Sub
End Class
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = "ABCDAEAFAG"
Dim Patter As String = "A"
Dim Matches As MatchCollection = Regex.Matches(str, Patter, RegexOptions.IgnoreCase Or RegexOptions.ExplicitCapture)
For Each ws In Matches
ListBox1.Items.Add("索引位置:" & ws.index)
Next
End Sub
End Class
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯