Solved

easy string manipulation

Posted on 2006-10-19
3
186 Views
Last Modified: 2012-05-05
Hi

I need to match strings to this format

1/5,
2/5
3/5
4/5
5/5


e.g. [1..5]/5

what's the easiest way to make sure an input string matches one of these values and then extract the number before the slash?

thanks
andrea
0
Comment
Question by:andieje
[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 18

Accepted Solution

by:
Ravi Singh earned 500 total points
ID: 17770307
Hi andrea, this should do what your after:

Imports System.Text.RegularExpressions
...

Dim Data As String = "1/5"
Dim Match As String = Regex.Match(Data, "(?<value>[1-5])/5").Groups("value").Value

If (Match <> String.Empty) Then
      'use Match string here (in this case it holds the string "1")
End If
0
 

Author Comment

by:andieje
ID: 17770610
you've become my regular expression guy (i presume you're a guy?)

:)
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17772424
yep, glad it worked :)
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

635 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