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 139521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:26:59+00:00 2026-05-11T07:26:59+00:00

I am expecting a String from an application that looks like: john|COL-DELIM|doe|COL-DELIM|55|ROW-DELIM|george|COL-DELIM|jetson|COL-DELIM|90|ROW-DELIM| I want

  • 0

I am expecting a String from an application that looks like:

john|COL-DELIM|doe|COL-DELIM|55|ROW-DELIM|george|COL-DELIM|jetson|COL-DELIM|90|ROW-DELIM|

I want to do two things:

1) Verify the string ‘looks’ correct (i.e. does it match a regex)

2) Pull out each ‘row’, then be able to parse each row

The values in between the delimiters (|COL-DELIM| and |ROW-DELIM|) can be any value (not just strings, numbers, whatever).

((.)(\|COL-DELIM\|)(.)(\|COL-DELIM\|)(.*)(\|ROW-DELIM\|))+

Naturally that doesn’t work b/c of the (.*) things…any suggestions?

  • 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. 2026-05-11T07:27:00+00:00Added an answer on May 11, 2026 at 7:27 am

    People don’t seem to get the fact that they don’t have to use REs (or SQL, but that’s another issue 🙂 for every task, especially those with procedural code is cleaner.

    If you’re limiting yourself to using REs, I think that’s a lack of vision.

    I would simply process the string, token by token, where a token is one of:

    • a non-delimiter.
    • a column delimiter.
    • a row delimiter.

    Start with an empty column list, then extract (using indexOf/substring stuff) up to the first next row/column delimiter, adding that text to the column list.

    If the delimiter is column, keep going.

    If the delimiter is row, check the number of columns and process the list as required.

    If there’s no final row delimiter and the column list is non-empty, then the format was invalid.

    Sorry if you were really after an RE method but I don’t believe it’s required (or even desirable) here.

    Pseudo-code (only a first cut, may be slightly buggy) follows:

    def processStr(s):     if not s.endsWith ('|ROW-DELIM|'):         error 'Invalid format'     columnList = []     while not s.equals (''):         nextRowDelim = s.indexOf ('|ROW-DELIM|')         nextColDelim = s.indexOf ('|COL-DELIM|')         if nextColDelim == NotFound:             nextColDelim = nextRowDelim + 1         nextDelim = minimumOf (nextRowDelim,nextColDelim)          columnList.add (s.substring (0, nextDelim))         s = s.substring (nextDelim)          if nextDelim == nextRowDelim:             s = s.substring (length ('|ROW-DELIM|'))             processColumns (columnList)             columnList = []         else:             s = s.substring (length ('|COL-DELIM|')) 

    You could easily add code to check the correct number of columns in this code, or in processColumns(), if that was your desire.

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

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I hate to say it (or rather the anti-table crowd… May 11, 2026 at 8:45 am
  • added an answer Most common application: it enables an anonymous function to call… May 11, 2026 at 8:44 am
  • added an answer this shows the different ways: -- DB2 select * from… May 11, 2026 at 8:44 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.