Five Stars

match whole file context using regex at once

Hi 
I have one regex that matches whole file content pattern. Its a text file.
How can I achieve this in talend.
I was trying like this 
tfileinputraw ----->tjavarow
String regex  = "(\\AX.*(?:\\r?\\n.*)*\\r?\\nZ.*(?:\\r?\\nX.*(?:\\r?\\n.*)*\\r?\\nZ.*)*\\z)";
context.regex = input_row.content.toString();
if (context.regex.matches(regex))
{
   System.out.println("valid");
}
else
{
  System.out.println("not valid");
}   
So its not working as expected. Any suggestions ?
1 REPLY
Twelve Stars

Re: match whole file context using regex at once

construction as is - work ( I use little more simple tFileInputFullRow -> tJavaFlex)
You must go from simple to complex, step-by-step
for example - change regex to simple (sample data - my own of course):

1709213380
valid
17153033806052016ABCD05082016YXA
not valid


So, the question - what You expect from Your regex pattern? dose it work on any regex tester? for example - https://regex101.com
-----------