从这里开始是我试图操纵的一个例子:
trait slot QName(PrivateNamespace("*", "com.company.assembleegameclient.ui:StatusBar"), "_-0IA") type QName(PackageNamespace(""), "Boolean") value False() end
我编写了一个代码,该代码将通过并读取每一行并停在相应的行。我现在想要实现的是阅读字符并保存
_-0IA
到一个新字符串。我尝试使用Trim(),Replace()和indexof到目前为止,但由于引号我遇到了很多困难。有没有人以前处理过这个问题?
答案 0 :(得分:1)
假设您的源字符串将始终遵循严格的格式,只有一些数据更改,这样的事情可能会起作用:
'Split the string by "," and extract the 3rd element. Trim the space and _
quotation mark from the front and extract the first 5 characters.
Dim targetstr As String = sourcestr.Split(","c)(2).TrimStart(" """.ToCharArray).Substring(0, 5)
如果目标字符串的长度是可变的,可以这样做:
Dim temp As String = teststr.Split(","c)(2).TrimStart(" """.ToCharArray)
'Use the index of the next quotation mark instead of a fixed length
Dim targetstr As String = temp.Substring(0, temp.IndexOf(""""c))