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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:17:57+00:00 2026-05-26T15:17:57+00:00

I need help with a regex to check if a line matches a line

  • 0

I need help with a regex to check if a line matches a line of pipe delineated data. The data will end with a pipe, and is not quoted. Some fields will be empty.

Here’s what I’m trying to use:

Pattern dataPattern = Pattern.compile("(.+)\\|^");

Here is a sample line of data:

GJ 3486|||121.10766667|-83.23302778|295.84892861999998|-24.832649669999999||-0.48399999999999999||.371|2MASS J08042586-8313589|8.9700000000000006|8.3539999999999992|8.1110000000000007||2MASS||

Since I only wanted to see if the line matched the pattern, I thought the one I came up with would look for “blah blah blah |”. Apparently not… can anyone help me out?

Jason

  • 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-05-26T15:17:57+00:00Added an answer on May 26, 2026 at 3:17 pm
    ^(.*?\|)*$
    

    Try this instead.

    "
    ^        # Assert position at the beginning of the string
    (        # Match the regular expression below and capture its match into backreference number 1
       .        # Match any single character that is not a line break character
          *?       # Between zero and unlimited times, as few times as possible, expanding as needed (lazy)
       \\|       # Match the character “|” literally
    )*       # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
    \$        # Assert position at the end of the string (or before the line break at the end of the string, if any)
    "
    

    Some problems with your regex :

    • Fist it is not repeating, you should repeat the pattern since you have many columns.
    • You match something and then you match tne start of the string. Not possible, this will never match.
    • You always want a character to match but you said there could be empty columns. Instead use * quantifier.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not a regex expert, but I know enough to be dangerous, need some help
I need help on regex or preg_match because I am not that experienced yet
I need some help using regex in java. Im trying to achieve 2 different
I need some help writing a regex. I have the following strings, xxx.yyy.wwwwwaaa_IN_123 xxx.rrrttttt_IN_12355
I need some help. I am looking for a regex that would match the
Can someone help me create this regex. I need it to check to see
I need some simple help with regex I want to grab the values in
need some help from a regex jedi master: If I have a string of
I need a little help with some regex I have. Basically I have a
Need Some Help With Regex: I want to replace [url=http://youtube.com]YouTube.com[/url] with <a href=http://youtube.com>YouTube.com</a> the

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.