Search code examples
javaregexmulemule-studiosplitter

Mule splitter using regex returned no results


I'm trying to split a csv file on lines. For this, I've tried alternatively with the following splitters on my flow:

<splitter expression="#[regex('^')]" doc:name="Splitter"/>

<splitter expression="#[regex('\n')]" doc:name="Splitter"/>

<splitter expression="#[regex('.*')]" doc:name="Splitter"/>

However, though the file has many lines, I'm getting the following message on the logs:

Splitter returned no results. If this is not expected, please check your split expression

Solution

  • Finally, I found a tutorial here with the solution: http://www.dotnetfunda.com/articles/show/2070/using-mule-studio-to-read-csv-comma-seperated-value-data-from-fileinbo

    The splitter has to be configured this way:

        <splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter" />
    

    And that requires the following element to be included on the flow:

    <configuration doc:name="Configuration">
        <expression-language autoResolveVariables="true">
            <import class="org.mule.util.StringUtils" />
        </expression-language>
    </configuration>