Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:37:58+00:00 2026-06-16T00:37:58+00:00

First time poster, long time user. I CAN NOT figure out why this data

  • 0

First time poster, long time user. I CAN NOT figure out why this data with this regular expression is passing when it should fail. The quick overview is that I have a text file with pipe delimited data in it. I’m reading each line in one at a time and comparing against a regex for pass/fail.

Here is the data in question:

|A|00032004|00032004|25 S Kings Highway||Cape Giradeau|MO|63701|345800886888|0000254575|091091|RGT Foods, Inc.|1|345800886888|1|345800886888|1|601103061404806|1|003241699917|0|000000000000|0|000000000000|0|000000000000|0|000000000000|
|A|00032005|00032005|1009 Kings Hwy||Rolla |MO|65401|345800885880|0000254564||RGT Foods, Inc.|1|345800885880|1|345800885880|1|601103061404798|1|003241699925|0|000000000000|0|000000000000|0|000000000000|0|000000000000|

Here’s the basic breakdown:
|D,U,or A|ID#|ID#|St Add1|St Add2|City|ST|Zip|#|#|Name|bool|#|bool|#|bool|#|bool|#|bool|#|bool|#|bool|#|bool|#|

This is my regular expression (warning: it’s kinda long):

^[\|]{1}[DUA]{1}[\|]{1}[0-9,A-Z]{8}[\|]{1}[0-9,A-Z]{8}[\|]{1}.{0,25}[\|]{1}.{0,25}[\|]{1}.{0,25}[\|]{1}[A-Z,a-z]{2}[\|]{1}[0-9]{5}[\|]{1}[A-Z,a-z,0-9]{12}[\|]{1}[A-Z,a-z,0-9]{10}[\|]{1}.{0,25}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}[0,1]{1}[\|]{1}[0-9]{15}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}[0,1]{1}[\|]{1}[0-9]{12}[\|]{1}

This is my regex function:

//Compare the entire line at once
public static bool MatchCCRegEx(string spLine)
{
    try
    {
        Regex CCLineCheck = new Regex(
                Properties.Settings.Default.CCRegExValidationString);
        Match CCLineMatch = CCLineCheck.Match(spLine);

        if (CCLineMatch.Success)
            return true;
        else
            return false;
    }
    catch (Exception RegExCheckExc)
    {
        WELogger.LogEvent("3", 
            "Error running RegEx check on this line:\r\n" 
            + spLine + "\r\n" + RegExCheckExc.ToString());

        Environment.Exit(9);
        return false;
    }
}

The example data I gave should fail because there is an extra field between # and Name with a value of 091091. The second line should also fail because of the extra field (but it’s empty on that one). I’ve stared at the regex for hours, because it looks like to me at the “#|#|Name|bool”, 091091 would’ve been put in for name and pass, but “RGT Foods, Inc.” shouldn’t pass as a 0 or 1…but both lines pass regex, what am i doing wrong?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:37:59+00:00Added an answer on June 16, 2026 at 12:37 am

    It’s a match because .{0,25} not only matches the RGT Foods, Inc. but also the 091091| before it.

    If you know your “free” fields won’t contain any pipes, replace .{0,25} with [^|]{0,25}. (“Zero to 25 not-a-pipe characters”.)

    Also, for readability, note

    • [\|] can be written [|] or \|.
    • {1} can be removed completely; the default is “match once”.
    • [A-Z,a-z,0-9] matches A-Z, a-z, 0-9 and commas. You probably mean [A-Za-z0-9]. Similarly [0,1] should be [01] and [0-9,A-Z] should be [0-9A-Z].

    Honestly, though, if you know your free fields can’t contain a pipe, I’d just String.Split on the pipe and validate each field separately. That regex is a nightmare.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long time lurker, first time poster; hoping anyone can help me out. Im using
Hy everyone, Long time reader, first time poster. This sounds like it should be
Long-time reader, first-time poster here. I'm trying to figure out how to sort a
First time poster, long time reader. I've been having a problem with figuring this
Long time lurker, first time poster. I have a page that can dynamically (with
I'm a long time reader first time poster, glad to start participating in this
First time poster long time reader. I've been playing round with reading in data
This is a pretty simple question; first time poster and long time looker. Here
Long time lurcher, first time poster here. I've been grappling with this problem for
Long time user, first time poster. I've found similar questions/answers, typically involving subqueries, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.