how to implement complex pattern matching in Spring batch using PatternMatchingCompositeLineMapper

后端 未结 1 507
既然无缘
既然无缘 2021-01-16 17:21

How can we implement pattern matching in Spring Batch, I am using org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper I got to know t

1条回答
  •  伪装坚强ぢ
    2021-01-16 18:13

    The PatternMatchingCompositeLineMapper uses an instance of org.springframework.batch.support.PatternMatcher to do the matching. It's important to note that PatternMatcher does not use true regular expressions. It uses something closer to ant patterns (the code is actually lifted from AntPathMatcher in Spring Core).

    That being said, you have three options:

    1. Use a pattern like you are referring to (since there is no short hand way to specify the number of ? that should be checked like there is in regular expressions).
    2. Create your own composite LineMapper implementation that uses regular expressions to do the mapping.

    For the record, if you choose option 2, contributing it back would be appreciated!

    0 讨论(0)
提交回复
热议问题