Class RegexLineTokenizer
java.lang.Object
org.springframework.batch.item.file.transform.AbstractLineTokenizer
org.springframework.batch.item.file.transform.RegexLineTokenizer
- All Implemented Interfaces:
LineTokenizer
Line-tokenizer using a regular expression to filter out data (by using matching and non-matching groups).
Consider the following regex which picks only the first and last name (notice the non-matching group in the middle):
(.*?)(?: .*)* (.*)For the names:
- "Graham James Edward Miller"
- "Andrew Gregory Macintyre"
- "No MiddleName"
- "Miller", "Graham"
- "Macintyre", "Andrew"
- "MiddleName", "No"
- Author:
- Costin Leau
- See Also:
-
Field Summary
Fields inherited from class org.springframework.batch.item.file.transform.AbstractLineTokenizer
names
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondoTokenize
(String line) void
setPattern
(Pattern pattern) Sets the regex pattern to use.void
Sets the regular expression to use.Methods inherited from class org.springframework.batch.item.file.transform.AbstractLineTokenizer
hasNames, isStrict, setFieldSetFactory, setNames, setStrict, tokenize
-
Constructor Details
-
RegexLineTokenizer
public RegexLineTokenizer()
-
-
Method Details
-
doTokenize
- Specified by:
doTokenize
in classAbstractLineTokenizer
-
setPattern
Sets the regex pattern to use.- Parameters:
pattern
- Regular Expression pattern
-
setRegex
Sets the regular expression to use.- Parameters:
regex
- regular expression (as a String)
-