如何在两个字符串之间使用字符串 [英] How Can I take String Between Two Strings
本文介绍了如何在两个字符串之间使用字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我正在使用VB.Net 2010,我想在两个字符串之间取字符串。
my string =ÿÿÿÿÿÿÿÿ^ 2hold up .._ AFC
我怎么能把这个^ 2持有......(长度永远不变。)
Hello,
I''m using VB.Net 2010 and i want take string between two strings.
my string = "ÿÿÿÿÿÿÿÿ^2hold up.._AFC"
How Can I take this "^2hold up.."(Lenght is never same.)
推荐答案
你听说过吗? RegEx [ ^ ]?
如果您想找到2持有
,请使用它:
Have you ever heard about RegEx[^]?
If you would like to find2hold up
, please use it:
Imports System.Text.RegularExpressions
Module Module1
Sub Main()
Dim sText As String = "ÿÿÿÿÿÿÿÿ^2hold up.._AFC"
Dim sPattern As String = "\b*(\^2hold up..)*\b"
Dim rx As Regex = New Regex(sPattern, RegexOptions.Singleline)
For Each m As Match In rx.Matches(sText)
Console.WriteLine(m.Value)
Next
Console.ReadKey()
End Sub
End Module
如果没有,请告诉我,我会尽力找到你正确的模式。
If not, please, let me know and i''ll try to find you proper pattern.
Dim s As String
s = "ÿÿÿÿÿÿÿÿ^2hold up.._AFC"
Dim start = s.IndexOf("ÿÿÿÿÿÿÿÿ") + Len("ÿÿÿÿÿÿÿÿ")
Dim limit = s.IndexOf("_AFC") - start
s = s.Substring(start, limit)
快乐编码!
:)
Happy Coding!
:)
这篇关于如何在两个字符串之间使用字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文