How can we implement pattern matching in Spring Batch, I am using org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper
I got to know that I can only use ? or * here to create my pattern.
My requirement is like below: I have a fixed length record file and in each record I have two fields at 35th and 36th position which gives record type for example below "05" is record type which is at 35th and 36th position and total length of record is 400.
0000001131444444444444445589868444050MarketsABNAKKAAAAKKKA05568551456...........
I tried to write regular expression but it does not work, i got to know only two special character can be used which are * and ? .
In that case I can only write like this ??????????????????????????????????05?????????????..................
but it does not seem to be good solution.
Please suggest how can I write this solution, Thanks a lot for help in advance
The
PatternMatchingCompositeLineMapper
uses an instance oforg.springframework.batch.support.PatternMatcher
to do the matching. It's important to note thatPatternMatcher
does not use true regular expressions. It uses something closer to ant patterns (the code is actually lifted fromAntPathMatcher
in Spring Core).That being said, you have three options:
LineMapper
implementation that uses regular expressions to do the mapping.For the record, if you choose option 2, contributing it back would be appreciated!