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
Solved

easy string manipulation

Posted on 2006-10-19
3
183 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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