Java Regular Expressions & BufferedReader

Hello,
I have a 256 char record consisting of fields of varying length with a slash "/" as the field delimiter. With this help of ddrudik, I was able to get past several of the blank fields, but
the matcher fails with the new non-blank fields. I can either make up a very long Expression or try to read  the next known chars that make up the entire record. I am confused as to how to read the "next n chars"  when I am using a bufferredReader as in br.readline(); for the initial read. I have a telemetry stream of data...

Thank You
dennisk1718Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dennisk1718Author Commented:
Hello,

Reading Friedl leads to a restatement of the problem.

I have a 256 char String to be parsed, with known fields at the 1 thru 12 char positions and at the
184-185 position. The actual discriminator is the field at 184-185 position with some elimination of disqualifying candiates occurring in the 1-12 character postions.
This is a telemtry stream at 9600 bps. Once the stream starts it does not stop. There are no end-of-record indicators in the stream as in "\n", etc. A known byte pattern defines start/end of record of interest.

WI have to recognize the start of the record inthe 1-12 char positions and thenb read to the 184-185 position to check those contents and if a match read to the 256 char position to save the record for parsing.

After a match in the 1-12th position, a region reset to run a usePattern() at 184-185 positon is a possibility?
But how do I read to and save the data over the whole 0-255 char string. ?

Thank You drrudik for your earlier repose and assistance

0
ddrudikCommented:
What rules do you use to determine a match at 184-185?  If no match at 184-185 you say you don't read on to 256th char, but do you then discard all 256 chars?  What determines the start of the string?  The fields vary in length but do they vary in quantity per record, and if so, how?
0
dennisk1718Author Commented:
Hello,
I have a simple two char match at pos 184-184: The Contents of the Interesting record is marked by the
be two chars AB at 184-185.

Yes, if AB is not found at 184-185 then I pitch the whole 156 chars and move to the next record that starts  with " {6}/ {2}/ {5}/ {2}/". The quantity of fields is fixed at 37 and the field delimieters are the "/" slashes.

Once I read a successful initial set of fields, I need to save the initial set and move to verify the presence of AB in the 184-185 position. If that is a sucess, I need to append the remaining chars out to position 255. I should probably save the intervening fields between the initial set success and the subsequent test at 184-185, as the stream is moving.

I am thinking of a usePattern() for the new match at 184-185.....

Thanks much



0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

dennisk1718Author Commented:
Hello,
Having a fixed number of fields delimited by "/", I have tried to use that fact to move the pointer so
to speak.
So for example, given a successful match at pos 1-12, as described earlier, ther are 26 "/" slashes to the 184-185 postion that constitutes the final check.
My tests on utilizing that piece of inof have not ben successful to date.

Thank You
0
ddrudikCommented:
I know little about the nuances of Java or working in it with data streams etc., so my assistance may only be from a regex perspective.

Considering that the string:
" {6}/ {2}/ {5}/ {2}/" (1-19) is the start of your record and it may contain "AB" at 184-185 then continue to 255 if "AB" is found:

The regex pattern (if I counted correctly) should be:
" {6}/ {2}/ {5}/ {2}/.{163}(?:AB.{90})?"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dennisk1718Author Commented:
Thank You for the ideas...
Most helpful
0
ddrudikCommented:
Thanks for the question and the points.
0
dennisk1718Author Commented:

Thank You
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.