Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want find a symbol (@) then find Start curly brack till end culry brack and read the value insid bracks..

C#
@{
    var="ak";
}


i tried it but not getting exact result...


pls help thankyou...
Posted
Comments
Sunasara Imdadhusen 4-Jun-13 6:00am    
Where is your code?
Anjanee Kumar Singh 4-Jun-13 6:03am    
int i = T1.Text.LastIndexOf("@{");
string s = T1.Text.Substring(T1.Text.LastIndexOf("@{"), T1.Text.LastIndexOf("}"));
MessageBox.Show(s);

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

VB
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


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

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

C#
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)
 
Share this answer
 
Comments
Anjanee Kumar Singh 4-Jun-13 9:24am    
it is giving only ';' but i need value inside '@{' and '}'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900