简体   繁体   English

只获取被“”包围的字符

[英]Only get characters surrounded by “ ”

I'm Currently writing a program that will convert my code into Pseudo Code but I'm having the problem that I cannot figure out how to get Only text that is surrounded by " " and comes after the word print. 我正在编写一个程序,将我的代码转换为伪代码,但我遇到的问题是我无法弄清楚如何获取只有被“”包围的文本并且在单词print之后。

Currently have 目前有

    Dim str() As String = TextBox1.Text.Split()
    If str.Contains("Print") Then

    End If

Nothing 没有

Here is one way. 这是一种方式。 Instead of splitting and then checking for Print , Check for Print first and then split it. 而不是拆分然后检查Print ,先检查Print然后拆分。

Tried and Tested 尝试和测试

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    If TextBox1.Text.Contains("Print") Then
        Dim ar As String = TextBox1.Text.Substring(TextBox1.Text.IndexOf("Print"))

        Dim splitted() As String = Split(ar, """")

        If splitted.Length > 1 Then MessageBox.Show(splitted(1))
    End If
End Sub

If the string is say This "is" a great Print Job! "Nice Work" 如果字符串是说“ This "is" a great Print Job! "Nice Work" This "is" a great Print Job! "Nice Work" then the above code should give you Nice Work This "is" a great Print Job! "Nice Work"然后上面的代码应该给你好Nice Work

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM