You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rory Gilfillan <ro...@itq.co.za> on 2018/06/19 11:24:26 UTC

Split with regex and group not working

The following code doesn't work:

           .split().tokenize("\n|\r\n", true, 100, true)


It tries to reinsert the token between the lines without taking into account that the token is a regex string.


The follow code in the GroupTokenIterator is the culprit:

            // include token in between
            if (data != null && count > 0 && token != null) {
                bos.write(token.getBytes());
            }


The contents of this email and any attachments are confidential, may be privileged and may only be read and used by the named recipient(s). If you have received it in error please contact the sender immediately and delete the e-mail. We endeavour to exclude viruses from our emails, but it is your responsibility to check this email for viruses. ITQ Business Solutions (Pty) Ltd accepts no liability or responsibility of whatsoever nature for any failure or loss arising in any way from the use of email as a means of communication.

Re: Split with regex and group not working

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah you can also provide a sample project / sample code / unit test
that demonstrates this issue.
That can help track down and fix the problem. And also log a JIRA
ticket so its not forgotten.

On Tue, Jun 19, 2018 at 10:20 PM, Alex Dettinger <al...@gmail.com> wrote:
> Hi Rory,
>
>   If I get it well the whole regex is inserted between lines while you were
> expecting to insert only the matching part of the regex.
> In that case, you are welcome to work on a fix or open a ticket.
>
>   At Apache Camel, we love contributions ;)
> https://github.com/apache/camel/blob/master/CONTRIBUTING.md
>
> Many thanks,
> Alex
>
> On Tue, Jun 19, 2018 at 1:24 PM, Rory Gilfillan <ro...@itq.co.za>
> wrote:
>
>> The following code doesn't work:
>>
>>            .split().tokenize("\n|\r\n", true, 100, true)
>>
>>
>> It tries to reinsert the token between the lines without taking into
>> account that the token is a regex string.
>>
>>
>> The follow code in the GroupTokenIterator is the culprit:
>>
>>             // include token in between
>>             if (data != null && count > 0 && token != null) {
>>                 bos.write(token.getBytes());
>>             }
>>
>>
>> The contents of this email and any attachments are confidential, may be
>> privileged and may only be read and used by the named recipient(s). If you
>> have received it in error please contact the sender immediately and delete
>> the e-mail. We endeavour to exclude viruses from our emails, but it is your
>> responsibility to check this email for viruses. ITQ Business Solutions
>> (Pty) Ltd accepts no liability or responsibility of whatsoever nature for
>> any failure or loss arising in any way from the use of email as a means of
>> communication.
>>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Split with regex and group not working

Posted by Alex Dettinger <al...@gmail.com>.
Hi Rory,

  If I get it well the whole regex is inserted between lines while you were
expecting to insert only the matching part of the regex.
In that case, you are welcome to work on a fix or open a ticket.

  At Apache Camel, we love contributions ;)
https://github.com/apache/camel/blob/master/CONTRIBUTING.md

Many thanks,
Alex

On Tue, Jun 19, 2018 at 1:24 PM, Rory Gilfillan <ro...@itq.co.za>
wrote:

> The following code doesn't work:
>
>            .split().tokenize("\n|\r\n", true, 100, true)
>
>
> It tries to reinsert the token between the lines without taking into
> account that the token is a regex string.
>
>
> The follow code in the GroupTokenIterator is the culprit:
>
>             // include token in between
>             if (data != null && count > 0 && token != null) {
>                 bos.write(token.getBytes());
>             }
>
>
> The contents of this email and any attachments are confidential, may be
> privileged and may only be read and used by the named recipient(s). If you
> have received it in error please contact the sender immediately and delete
> the e-mail. We endeavour to exclude viruses from our emails, but it is your
> responsibility to check this email for viruses. ITQ Business Solutions
> (Pty) Ltd accepts no liability or responsibility of whatsoever nature for
> any failure or loss arising in any way from the use of email as a means of
> communication.
>