Solved

easy string manipulation

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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