有啊,用正则表达式,下面是简单的例子
凭借整站使用H5技术的创新体验、定制设计、设计团队积累与透明式的服务过程,符合行业特点,专属顾问根据企业产品,消费群体属性,准确定位;设计师以目标客户为中心,以突出品牌官网特性为宗旨,定制专属网站建设设计方案。
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
请参考下面的代码,希望能帮到你。
假设在richtextbox1中查找字符串"你是谁":
Dim start As Integer = richtextbox1.Find("你是谁", 0, RichTextBoxFinds.MatchCase)
if (start = 0) {
richtextbox1.SelectionStart = start
richtextbox1.SelectionLength = "你是谁".Length
}
很简单,用字符串查找函数就可以实现了。\x0d\x0a当在StrB查找到StrA字符串时,返回肯定是非0的数,值就是True,找不到为0或者-1,值就是Flase\x0d\x0a\x0d\x0a比如:\x0d\x0aDim StrA As String = "Time is Limited"\x0d\x0aDim StrB As String = "Time"\x0d\x0aDim Stu As Boolean= InStr(StrA, StrB)\x0d\x0a\x0d\x0a这运行段代码,Stu值就是True了。\x0d\x0a我觉得这样最简单有效。
简单点写。
Module Program
Sub Main()
Console.WriteLine("Hello World!")
Dim t As String, a() As String, c As Integer
t="/admin/index/login/defasd.php"
a=t.Split("/"c)
c=0
For Each p In a
If c0 Then
Console.WriteLine("/"+p)
End If
c+=1
Next
Console.Write("Press any key to continue . . . ")
Console.ReadKey(True)
End Sub
End Module
========
Hello World!
/admin
/index
/login
/defasd.php
正则表达式:“第\S{1,3}次”
1-3表示第和次之间可能存在1-3个字符。
For Each i In System.Text.RegularExpressions.Regex.Matches("你的内容第一次第三次第十四次第七十七次替换为", "第\S{1,3}次")
MsgBox(i.value())
Next
dim st as string = "qwertyuiop"
msgbox(st.indexof("p"))
若为-1,则表示不存在