Solved

easy string manipulation

Posted on 2006-10-19
3
180 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
Comment Utility
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
Comment Utility
you've become my regular expression guy (i presume you're a guy?)

:)
0
 
LVL 18

Expert Comment

by:Ravi Singh
Comment Utility
yep, glad it worked :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Object to array 7 27
Duplicate a row 2 29
Expando 4 33
AutoHotkey ActiveX Component Error 8 55
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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

17 Experts available now in Live!

Get 1:1 Help Now