Solved

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

Posted on 2008-10-08
3
213 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
[X]
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
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 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