Results 1 to 2 of 2

Thread: Regex and VB6

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Regex and VB6

    So I am trying to convert this from VB6 into C# but cannot figure out the Regex in C#.

    Code:
    if theData Like "[*]??????????????8" then
    ...
    so in C#, what would the regex be?

    I tried:
    [*]??8

    but this returns true even if it does not end in "8"

    sure, could use the "string" way (get the last char and see if it is an 8 or use IndexOf) but that is not the best way and rather have Regex only.

    Thanks

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Re: Regex and VB6

    csharp Code:
    1. if (Regex.IsMatch(theData, "\\*.{14}8")) { //... }
    should do the trick.
    There are various additions like ^$ for beginning/end of string (singleline option), or grouping that could be used, but for this example, the base matching of asterisk following by 14 of any single char followed by 8, should be adequate.

    Tom
    In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width