Solved

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

Posted on 2008-10-08
3
211 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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