regex match new line doesnt work

Four Stars

regex match new line doesnt work

hi,

 

want to to match a line from a text file:

 

gtniUA8

in a tJavaRow:

output_row.line = input_row.line;
String regex = "\\d{7}\\n";
java.util.regex.Matcher m = java.util.regex.Pattern.compile(regex).matcher(input_row.line);
   if(m.find()){
      System.out.println(m.group(0).trim().substring(0,7));
   }

this "\\n" doestn match the "LF", what could i do?

 


Accepted Solutions
Thirteen Stars

Re: regex match new line doesnt work

Hi,

 

it is because - if you (as usual) read file row by row, Talend already truncate this LF from the line (default line separator)

but if you test with tInputFileRow (don't forget to convert it to string) - regex will work

-----------

All Replies
Thirteen Stars

Re: regex match new line doesnt work

Hi,

 

it is because - if you (as usual) read file row by row, Talend already truncate this LF from the line (default line separator)

but if you test with tInputFileRow (don't forget to convert it to string) - regex will work

-----------
Four Stars

[solved] Re: regex match new line doesnt work

awesome! thank you!

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.