locked
RegEx Help - Match Whole Word with Hypens RRS feed

  • Question

  • User-995155577 posted

    I have a string that looks like this:

    219259-1, 219259-2, 219259-2, 219259


    I'm trying to do an IsMatch using:

    Dim liccheck As New Regex("\b" + licensenum + "$")


    The problem is the hypen is not getting caught because it is not a word character. I can not figure out how to match the whole word? I tried using /w as well with no luck. Any ideas?

    Wednesday, April 14, 2010 4:13 PM

Answers

All replies

  • User187056398 posted

    It might be the comma:

    ("\b" + licensenum + "[,$]")

     

    Ultrapico
    This site has a great free tool for building Regular Expressions (Expresso).
    Wednesday, April 14, 2010 5:21 PM
  • User-995155577 posted

    No luck. I ended up using string.split and just loop through the array. I will give that RegEx tool a look.


    thanks,

    Dan


    Thursday, April 15, 2010 4:13 PM
  • User-952121411 posted

    You might find someone here with help on Regular Expressions, but I typically go to the forum where people eat, sleep, and breath RegEx stuff; they are always a big help:

    Regular Expressions Forum:

    http://social.msdn.microsoft.com/Forums/en-US/regexp/threads

    ...another quick 'recipe cookbook style' resource for tested Regular Expressions (searchable site too) is the RegEx Library link below:

    http://regexlib.com/Search.aspx

    Hope this helps! Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 16, 2010 10:22 AM