I am new to servicemix/camel and not the greatest at regex but any help would be grateful.
I have a route which splits a file and converts each line into a class via bindy. This works fine. However, i only want lines which match a regex.
Using http://gskinner.com/RegExr/ i've checked my regex matches the test data, but when i run the route, all lines go to "Didnt match regex".
<split>
<tokenize token="\n"/>
<choice>
<when>
<!-- Regex: Matches on A, U or D followed by pipe | then ANYTHING, i.e.: A|azz454... -->
<simple>${body} regex '^[AUD]\|.*'</simple>
<unmarshal ref="bindyMasterProduct" />
<log message="OUTPUT: ${body}"/>
</when>
<otherwise>
<log message="Didnt match regex: ${body}"/>
</otherwise>
</choice>
</split>
Regex:
^[AUD]\|.*
Match:
A|AZZ709256|Cheryl
DONT-Match:
Mode|Ref|Name
I realised i was going about the problem the wrong way. I dont need to to split the file at line level, i can just let bindy do it all for me.
I added the "skipFirstLine" annotation to my class and replaced the whole of the split xml with:
<unmarshal ref="bindyMasterProduct" />