Reading rows using a regular expression
Regular expression (regex) is a powerful method for pattern matching and replacement within many programming languages, and is outside the scope of this book (a good starting point is the javadocs for regex patterns at http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html). One interesting use for regular expressions is when dealing with unusual input formats that are difficult to describe using normal delimited or fixed-width file formatting. This recipe shows how regex can be used to identify a set of input columns from an unstructured input row.
Getting ready
The screenshot of the chapter8_jo_0020_jobLogData.txt
file is as follows:
You should notice that there is neither an obvious delimiter, nor does each record fit a fixed width format.
Now, open the jo_cook_ch08_0020_readRegexData
job.
How to do it...
The steps for reading rows using regular expressions are as follows:
Open
tFileInputRegex
and enter the following code:"^job: "+ ...