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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:48:48+00:00 2026-05-20T18:48:48+00:00

I have a flat file like: A 10 S 20 W A 20 10

  • 0

I have a flat file like:

A 10
S 20
W A 20 10
S A 45 10
S W S 20 20 20 30
W A S 22 50 20 55

I want to make sure it is well formed, (separated by blank space ” “)
allowing only a regular expression like:

anyword* then " " then (word*|numbers*)*

where * is any number of words
but there is also one issue,

  • if there is only one word or char there is only one number
  • if there are 2 words or chars separated by ” ” then there must be 2 numbers separated by ” “
  • if there are 3 words or chars separated by ” ” then there must be 4 numbers separated by ” “

I was doing something like this, but do not know where to incorporate validation of line

try {
      input = new BufferedReader(new FileReader(new File(filename)));
      String line = null;
      while ((line = input.readLine()) != null) {
           String[] words = line.split(" ");
       if (words.length == 2) {

           }
     }  
 }
  • 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-20T18:48:48+00:00Added an answer on May 20, 2026 at 6:48 pm

    This regex should do it:

    ^[a-z]+ (?:\d+|[a-z]+(?: \d+ \d+| [a-z]+(?: \d+){4}))$
    

    I tried to make it as short as possible, but it may be possible to condense it a bit more. This should be used with case sensitivity enabled or you should change all of the [a-z] to [a-zA-Z].

    Here is a Rubular.

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

Sidebar

Related Questions

I have a flat file source from Excel that has a structure like this:
I have problem with this code..I want to extract data from flat file and
I have simple SSIS package which reads data from flat file and insert into
I have an OLE DB Data source and a Flat File Destination in the
I have simple SSIS package where I import data from flat file into SQL
I have a windows mobile 5.0 application (smartphone) that contains a flat data file
I have a tab delimited file on a shared path. I've setup that flat
I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
I have a flat file of a dataset with 100 rows and 2001 attributes
I have a txt file that I’m trying to import as flat file into

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.