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
Forteen 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
Forteen 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!

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog