How to use regex

Tags: #<Tag:0x00007f70c056b9d0> #<Tag:0x00007f70c056b840>

At first create a IConfiguration

IConfiguration configuration = new DefaultConfiguration();

For this configuration now set the filter patterns with property PDFCProperty.FILTER_PATTERNS

For a filted document based on separated numbers use the following lines

configuration.putValue( PDFCProperty.FILTER_PATTERNS, 
    + "\\s\\d+$|regexp|active\n"
    + "^\\d+\\s|regexp|active\n"
    + "\\s\\d+\\s|regexp|active\n"
    + "^\\d+$|regexp|active\n"
);

For a filted document based on dates use the following lines

configuration.putValue( PDFCProperty.FILTER_PATTERNS, 
    + "((19|20)\\d\\d([- /.])(0[1-9]|1[012])([- /.])(0[1-9]|[12][0-9]|3[01]))|regexp|active\n"
    + "((0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\\d\\d)|regexp|active\n"
);

For a filted document based on lenght units use the following lines

configuration.putValue( PDFCProperty.FILTER_PATTERNS, 
    + "\\s(mm|cm|dm|m|km)|regexp|active\n"
);

After setting the filter option, another option has to be set to activate the filter. Make sure to add all further required filters here as well.

configuration.putValue( PDFCProperty.CONTINUOUS_FILTERS, "REGEXP" );

Now you can use the configuration for a comparison.

pdfComparer.setConfiguration( configuration ).compare( <file1>, <file2> )

View full sourcecode

© Copyright 1996 - 2018, i-net software; All Rights Reserved.