PatternBuilder question.

jpfr7 years ago

Hello,

I have started to look around and learn how the code works to be able to make some new features that I need for a project I am working on.

So I looked at the pattern builder class and wanted to know if what I have done is good or I made a mistake.


PatternBuilder()
            .number("[^d]*")                     // deader
            .number("(d+),")                     // device identifier
            .number("(dddd)(dd)(dd)")            // date (yyyymmdd)
            .number("(dd)(dd)(dd),")             // time (hhmmss)
            .number("(d+),")                     // event
            .number("(d+),")                     // level
            .text("(a-zZ-a0-9+),")               // cid
            .text("(a-zZ-a0-9+)")                // vid
            .any()
            .compile();

It is mostly for the end I am not sure if the text works like that.
Here is an example of what the data could look like.

1101010101,20170529132239,88,4371,C52093,D35759

I used .text() since it could be alphanumeric and added a + to say it could be any number of alphanumeric charters.

Thank you.
Best regards
Jp

Anton Tananaev7 years ago

The "text" method is for static text. It's not for patterns. If you need a pattern, you should use "expression". There might be a problem with first line as well.

jpfr7 years ago

Ok thanks a lot :)

Best regards.
Jp