Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

20 Experts available now in Live!

Get 1:1 Help Now