在richtextbox中查找符号并在side bracks中读取值 [英] find symbol in richtextbox and read value in side bracks

查看:97
本文介绍了在richtextbox中查找符号并在side bracks中读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找一个符号(@)然后找到开始卷曲的括号,直到结束culry brack并读取值insid bracks ..



i want find a symbol (@) then find Start curly brack till end culry brack and read the value insid bracks..

@{
    var="ak";
}





i尝试了但没有得到确切的结果...





请帮助thankyou ...



i tried it but not getting exact result...


pls help thankyou...

推荐答案

你好,



你在子串函数的长度参数中有一个错误。

这段代码(在VB.NET中)工作正常:



Hello,

You have an error in the length parameter of the Substring function.
This code (in VB.NET) works fine :

RichTextBox1.Text = "test@{test.fr}"
Dim i As Integer = RichTextBox1.Text.LastIndexOf("@{")
Dim s As String = RichTextBox1.Text.Substring(i, RichTextBox1.Text.LastIndexOf("}") - i + 1)
MessageBox.Show(s)


我稍微修改一下这个函数(子串调用的索引)



I modify the function a little (the indexes for Substring call)

Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        RichTextBox1.Text = "test@{test.fr}"
        Dim i As Integer = RichTextBox1.Text.LastIndexOf("@{")
        Dim s As String = RichTextBox1.Text.Substring(i+2, RichTextBox1.Text.LastIndexOf("}") - (i+2))
        MessageBox.Show(s)

    End Sub

End Class





此代码在MessageBox中返回test.fr。所以,@ {和}之间的值。



This code returns "test.fr" in the MessageBox. So, the value between "@{" and "}".


这篇关于在richtextbox中查找符号并在side bracks中读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆