Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Get Value Inside Bracket

Posted on 2009-04-06
Medium Priority
Last Modified: 2012-05-06

I want to get value inside bracket.

ie. Char(6) --> 6
     VarChar(6) ---> 6

Is there a simple way to do it than using instr function ?

Thank you.
Question by:emi_sastra
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 48

Accepted Solution

jpaulino earned 1000 total points
ID: 24075546
Here's a way
        Dim str As String = "Char(6)"
        Dim sep() As Char = New Char() {"(", ")"}
        Dim result() As String = str.Split(sep)

Open in new window

LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 1000 total points
ID: 24075551
The easiest method is to use Regular Expressions....
        Dim s As String = "VarChar(6)"
        Dim regex As New System.Text.RegularExpressions.Regex("\((\d+)\)")
        Dim num As Integer = Convert.ToInt32(regex.Match(s).Groups(1).Value)

Open in new window


Author Comment

ID: 24075610
Hi All,

Let me try first.

Thank you.

Author Comment

ID: 24075654
Hi All,

It all works.

Thank you very much for your help.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question