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?
 
ddrudikConnect With a Mentor Commented:
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
 
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
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
 
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
 
dennisk1718Author Commented:
Thank You for the ideas...
Most helpful
0
 
ddrudikCommented:
Thanks for the question and the points.
0
 
dennisk1718Author Commented:

Thank You
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.