字符串类的视觉基础 [英] string class visual basic
问题描述
Dim strmystring as stirng = "record0030040acd035a856ab"
在这种情况下,我想找到040(但可能是034或856)
In this case I want to find 040 (but it could be 034 or 856)
Dim I as interger = strmystring.indexof("040")
Next ouput the substring
Dim strsubstring as string = strmystring.substring(i)
现在我的表情看起来像"040acd035a856ab"
有了这个字符串,我如何输出休憩:
040a
040c
040d
因此,我想使用040之后的字母,请多加考虑.
Now my stirng looks like "040acd035a856ab"
With this string how can I output the fallowing:
040a
040c
040d
So I want the alphabets after 040, appreciate any ideas.
推荐答案
如果您只需要接下来的4个字符...则将您的子字符串行更改为: br/>
If you know it only needs the next 4 characters...change your substring line to this:
Dim strsubstring as string = strmystring.substring(i,4)
子字符串函数的第二个parm表示您要提取接下来的4个字符.
---糟糕...我对您的问题听不清...
您需要像以前一样拉动整个过程.我猜想您可以遍历字符串并查找第一个字母是alpha ...您可以使用 ^ ]函数.或者您可以找出一种使用正则表达式的方法.
这是 ^ ]用于正则表达式.这是 CP文章 [
The second parm on the substring function means you want to pull the next 4 characters.
--- oops...I didn''t read your question well enough...
You''ll need to pull the whole thing like you did before. I suppose then you could loop through the string and look for the first character that is alpha...you could use the IsNumeric[^] function. Or you could figure out a way to do it with regular expressions.
Here are google results[^] for regular expressions. Here are CP Articles[^] for regular expressions. These should help you get started.
我已经写了:
I have written it:
Module Module1
Sub Main()
Dim Str = "record0030040acd035a856ab"
Dim I = Str.IndexOf("040")
For a = I + 3 To Str.Length - 1
Dim Chr = Str(a)
If Char.IsLetter(Chr) Then
Console.WriteLine("040" + Chr)
Else
Exit For
End If
Next
End Sub
End Module
这篇关于字符串类的视觉基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!