Solved

What is the correct way to use Regex for this probelm?

Posted on 2008-10-08
3
210 Views
Last Modified: 2013-12-17
I have a string that is built something like this.

Dim strTest As New System.Text.StringBuilder

        For I = 1 To 100
            strTest.Append(Chr(128))
            strTest.Append(I.ToString)
            strTest.Append(Chr(129))
        Next

        Dim regPart As New System.Text.RegularExpressions.Regex(Chr(128) + ".*" + Chr(129))
        For Each matchPart As System.Text.RegularExpressions.Match In regPart.Matches(strTest.ToString)
            Dim strTest2 As String = matchPart.ToString
        Next

What I want the regex to do is return 100 matches, but what it is doing is returning one match that is the entire string.

What am I doing wrong?

0
Comment
Question by:pamsauto
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
ddrudik earned 500 total points
ID: 22668908
Dim regPart As New System.Text.RegularExpressions.Regex(Chr(128) + ".*?" + Chr(129))
0
 

Author Comment

by:pamsauto
ID: 22668950
Thanks!
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 22668980
Thanks for the question and the points.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now