我在Textabc
中有多个带有“123”字样的文字如a123b,c123erf和123
但我只是想找到确切的单词“123”
Text_u1 = Mid(Textabc, InStr(Text, "123"))
我试过& 123&但没有工作
谢谢
答案 0 :(得分:2)
Option Explicit
Sub GetWord()
Dim Textabc As String, s As Variant, i As Variant, abc As String, sz As Long
Dim foundStart As Long, foundLen As Long
Textabc = "like a123b , c123erf and 123"
abc = "123"
s = Split(Textabc)
For i = 0 To UBound(s)
sz = sz + Len(s(i)) + 1
If Trim(s(i)) = abc Then
foundStart = sz - Len(s(i))
foundLen = Len(Textabc) - (sz - Len(s(i))) + 1
Debug.Print "Textabc length: " & Len(Textabc)
Debug.Print "foundStart: " & foundStart
Debug.Print "foundLen: " & foundLen
Debug.Print Mid(Textabc, foundStart, foundLen)
End If
Next
End Sub
答案 1 :(得分:1)
根据您的需要,尝试以下两种方法之一:
@if (Auth::user()->email == 'evangelism.sec@gmail.com')
//your code after authentication
@else
//user not logged in
@endif
答案 2 :(得分:1)
您可以尝试使用正则表达式
Sub Test()
Dim regEx As Object
Dim str As String
Set regEx = CreateObject("vbscript.RegExp")
str = "a123b , c123erf and 123"
With regEx
.Global = True
.IgnoreCase = True
.Pattern = "\b(123)"
Debug.Print regEx.Execute(str)(0).FirstIndex + 1
End With
End Sub
这将返回它找到的第一个匹配的位置,该位置仅等于123
其他所有内容都将被忽略。如果有多个匹配项,则需要循环regEx.Execute(str)
的输出以获得每个位置