Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

easy string manipulation

Posted on 2006-10-19
3
Medium Priority
?
187 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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