Grab text from string, ignore text within [brackets]

Hello all;

I am using the following code, to grab the text between (text here) and [text here]
			Dim strWriters as string = "(somebody here) [Something else here]"
			Dim Regex As Regex = New Regex("\(.*?\)")
			Dim Regex1 As Regex = New Regex("\[.*?\]")

			Dim matches As MatchCollection = Regex.Matches(strWriters)
			Dim matches1 As MatchCollection = Regex1.Matches(strWriters)

			Dim count As Integer = matches.Count
			Dim counts As Integer = matches1.Count

			Dim s0 As String = matches(0).Value.ToString
			Dim s1 As String = matches1(0).Value.ToString

Open in new window


The above works great, however. I want to eliminate the use of the Parentheses (text here) altogether.
I still need to grab the text in the brackets, so the brackets have to remain.

Like the code above.
Grab the "somebody here" from the string
And then, another one will grab the Something else here.

Dim strWriters as string = "somebody here [Something else here]"

Open in new window


Assistance on this would be great.
Thanks in advance.
Carrzkiss
LVL 31
Wayne BarronAuthor, Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical SpecialistCommented:
Dim strWriters as string = "somebody here [Something else here]"
Dim Regex As Regex = New Regex("\[.*?\]")

Dim matches As MatchCollection = Regex.Matches(strWriters)
Dim count As Integer = matches.Count
Dim s As String = matches(0).Value.ToString

Open in new window

0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
I do not see how this works.
I did a response.write(s)
And it printed out the full string.
Could you elaborate on how to use this, please?
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
Never mind my first comment.
I ran it again, and it gets the text in the brackets.
that is not what I asked for.
I asked to ignore the text in the brackets.
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Wayne BarronAuthor, Web DeveloperAuthor Commented:
I found something that works.

Dim leftString = sampleInput.Substring(0, sampleInput.IndexOf("["))
Response.Write(leftString)

Open in new window


I am set, this is what I needed.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun VermaakTechnical SpecialistCommented:
I do not see how this works.
I did a response.write(s)
And it printed out the full string.
Could you elaborate on how to use this, please?
I assumed your initial code worked
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
Found a solution on my own.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.