Package org.apache.beam.sdk.transforms
Class Regex
java.lang.Object
org.apache.beam.sdk.transforms.Regex
PTransforms to use Regular Expressions to process elements in a PCollection.
matches(String, int) can be used to see if an entire line matches a Regex.
matchesKV(String, int, int) can be used to see if an entire line matches a Regex
and output certain groups as a KV.
find(String, int) can be used to see if a portion of a line matches a Regex.
matchesKV(String, int, int) can be used to see if a portion of a line matches a
Regex and output certain groups as a KV.
Lines that do not match the Regex will not be output.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRegex.MatchesName<String>takes aPCollection<String>and returns aPCollection<List<String>>representing the value extracted from all the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.Find<String>takes aPCollection<String>and returns aPCollection<String>representing the value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.Find<String>takes aPCollection<String>and returns aPCollection<List<String>>representing the value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.MatchesKV<KV<String, String>>takes aPCollection<String>and returns aPCollection<KV<String, String>>representing the key and value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.Find<String>takes aPCollection<String>and returns aPCollection<String>representing the value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.MatchesKV<KV<String, String>>takes aPCollection<String>and returns aPCollection<KV<String, String>>representing the key and value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.Matches<String>takes aPCollection<String>and returns aPCollection<String>representing the value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.MatchesKV<KV<String, String>>takes aPCollection<String>and returns aPCollection<KV<String, String>>representing the key and value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.MatchesName<String>takes aPCollection<String>and returns aPCollection<String>representing the value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.MatchesNameKV<KV<String, String>>takes aPCollection<String>and returns aPCollection<KV<String, String>>representing the key and value extracted from the Regex groups of the inputPCollectionto the number of times that element occurs in the input.static classRegex.ReplaceAll<String>takes aPCollection<String>and returns aPCollection<String>with all Strings that matched the Regex being replaced with the replacement string.static classRegex.ReplaceFirst<String>takes aPCollection<String>and returns aPCollection<String>with the first Strings that matched the Regex being replaced with the replacement string.static classRegex.Split<String>takes aPCollection<String>and returns aPCollection<String>with the input string split into individual items in a list. -
Method Summary
Modifier and TypeMethodDescriptionstatic Regex.AllMatchesallMatches(String regex) Returns aRegex.AllMatchesPTransformthat checks if the entire line matches the Regex.static Regex.AllMatchesallMatches(Pattern pattern) Returns aRegex.AllMatchesPTransformthat checks if the entire line matches the Regex.static Regex.FindReturns aRegex.FindPTransformthat checks if a portion of the line matches the Regex.static Regex.FindReturns aRegex.FindPTransformthat checks if a portion of the line matches the Regex.static Regex.FindNameReturns aRegex.FindNamePTransformthat checks if a portion of the line matches the Regex.static Regex.FindReturns aRegex.FindPTransformthat checks if a portion of the line matches the Regex.static Regex.FindReturns aRegex.FindPTransformthat checks if a portion of the line matches the Regex.static Regex.FindNameReturns aRegex.FindNamePTransformthat checks if a portion of the line matches the Regex.static Regex.FindAllReturns aRegex.FindAllPTransformthat checks if a portion of the line matches the Regex.static Regex.FindAllReturns aRegex.FindAllPTransformthat checks if a portion of the line matches the Regex.static Regex.FindKVReturns aRegex.FindKVPTransformthat checks if a portion of the line matches the Regex.static Regex.FindNameKVReturns aRegex.FindNameKVPTransformthat checks if a portion of the line matches the Regex.static Regex.FindKVReturns aRegex.FindKVPTransformthat checks if a portion of the line matches the Regex.static Regex.FindNameKVReturns aRegex.FindNameKVPTransformthat checks if a portion of the line matches the Regex.static Regex.MatchesReturns aRegex.MatchesPTransformthat checks if the entire line matches the Regex.static Regex.MatchesReturns aRegex.MatchesPTransformthat checks if the entire line matches the Regex.static Regex.MatchesNameReturns aRegex.MatchesNamePTransformthat checks if the entire line matches the Regex.static Regex.MatchesReturns aRegex.MatchesPTransformthat checks if the entire line matches the Regex.static Regex.MatchesReturns aRegex.MatchesPTransformthat checks if the entire line matches the Regex.static Regex.MatchesNameReturns aRegex.MatchesNamePTransformthat checks if the entire line matches the Regex.static Regex.MatchesKVReturns aRegex.MatchesKVPTransformthat checks if the entire line matches the Regex.static Regex.MatchesNameKVReturns aRegex.MatchesNameKVPTransformthat checks if the entire line matches the Regex.static Regex.MatchesKVReturns aRegex.MatchesKVPTransformthat checks if the entire line matches the Regex.static Regex.MatchesNameKVReturns aRegex.MatchesNameKVPTransformthat checks if the entire line matches the Regex.static Regex.ReplaceAllreplaceAll(String regex, String replacement) Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces all matches with the replacement String.static Regex.ReplaceAllreplaceAll(Pattern pattern, String replacement) Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces all matches with the replacement String.static Regex.ReplaceFirstreplaceFirst(String regex, String replacement) Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces the first match with the replacement String.static Regex.ReplaceFirstreplaceFirst(Pattern pattern, String replacement) Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces the first match with the replacement String.static Regex.SplitReturns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item.static Regex.SplitReturns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item.static Regex.SplitReturns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item.static Regex.SplitReturns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item.
-
Method Details
-
matches
Returns aRegex.MatchesPTransformthat checks if the entire line matches the Regex. Returns the entire line (group 0) as aPCollection.- Parameters:
regex- The regular expression to run
-
matches
Returns aRegex.MatchesPTransformthat checks if the entire line matches the Regex. Returns the entire line (group 0) as aPCollection.- Parameters:
pattern- The regular expression to run
-
matches
Returns aRegex.MatchesPTransformthat checks if the entire line matches the Regex. Returns the group as aPCollection.- Parameters:
regex- The regular expression to rungroup- The Regex group to return as a PCollection
-
matches
Returns aRegex.MatchesPTransformthat checks if the entire line matches the Regex. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to rungroup- The Regex group to return as a PCollection
-
matches
Returns aRegex.MatchesNamePTransformthat checks if the entire line matches the Regex. Returns the group as aPCollection.- Parameters:
regex- The regular expression to rungroupName- The Regex group name to return as a PCollection
-
matches
Returns aRegex.MatchesNamePTransformthat checks if the entire line matches the Regex. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to rungroupName- The Regex group name to return as a PCollection
-
allMatches
Returns aRegex.AllMatchesPTransformthat checks if the entire line matches the Regex. Returns all groups as a List<String> in aPCollection.- Parameters:
regex- The regular expression to run
-
allMatches
Returns aRegex.AllMatchesPTransformthat checks if the entire line matches the Regex. Returns all groups as a List<String> in aPCollection.- Parameters:
pattern- The regular expression to run
-
matchesKV
Returns aRegex.MatchesKVPTransformthat checks if the entire line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
regex- The regular expression to runkeyGroup- The Regex group to use as the keyvalueGroup- The Regex group to use the value
-
matchesKV
Returns aRegex.MatchesKVPTransformthat checks if the entire line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
pattern- The regular expression to runkeyGroup- The Regex group to use as the keyvalueGroup- The Regex group to use the value
-
matchesKV
public static Regex.MatchesNameKV matchesKV(String regex, String keyGroupName, String valueGroupName) Returns aRegex.MatchesNameKVPTransformthat checks if the entire line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
regex- The regular expression to runkeyGroupName- The Regex group name to use as the keyvalueGroupName- The Regex group name to use the value
-
matchesKV
public static Regex.MatchesNameKV matchesKV(Pattern pattern, String keyGroupName, String valueGroupName) Returns aRegex.MatchesNameKVPTransformthat checks if the entire line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
pattern- The regular expression to runkeyGroupName- The Regex group name to use as the keyvalueGroupName- The Regex group name to use the value
-
find
Returns aRegex.FindPTransformthat checks if a portion of the line matches the Regex. Returns the entire line (group 0) as aPCollection.- Parameters:
regex- The regular expression to run
-
find
Returns aRegex.FindPTransformthat checks if a portion of the line matches the Regex. Returns the entire line (group 0) as aPCollection.- Parameters:
pattern- The regular expression to run
-
find
Returns aRegex.FindPTransformthat checks if a portion of the line matches the Regex. Returns the group as aPCollection.- Parameters:
regex- The regular expression to rungroup- The Regex group to return as a PCollection
-
find
Returns aRegex.FindPTransformthat checks if a portion of the line matches the Regex. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to rungroup- The Regex group to return as a PCollection
-
find
Returns aRegex.FindNamePTransformthat checks if a portion of the line matches the Regex. Returns the group as aPCollection.- Parameters:
regex- The regular expression to rungroupName- The Regex group name to return as a PCollection
-
find
Returns aRegex.FindNamePTransformthat checks if a portion of the line matches the Regex. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to rungroupName- The Regex group name to return as a PCollection
-
findAll
Returns aRegex.FindAllPTransformthat checks if a portion of the line matches the Regex. Returns all the groups as a List<String> in aPCollection.- Parameters:
regex- The regular expression to run
-
findAll
Returns aRegex.FindAllPTransformthat checks if a portion of the line matches the Regex. Returns all the groups as a List<String> in aPCollection.- Parameters:
pattern- The regular expression to run
-
findKV
Returns aRegex.FindKVPTransformthat checks if a portion of the line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
regex- The regular expression to runkeyGroup- The Regex group to use as the keyvalueGroup- The Regex group to use the value
-
findKV
Returns aRegex.FindKVPTransformthat checks if a portion of the line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
pattern- The regular expression to runkeyGroup- The Regex group to use as the keyvalueGroup- The Regex group to use the value
-
findKV
Returns aRegex.FindNameKVPTransformthat checks if a portion of the line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
regex- The regular expression to runkeyGroupName- The Regex group name to use as the keyvalueGroupName- The Regex group name to use the value
-
findKV
Returns aRegex.FindNameKVPTransformthat checks if a portion of the line matches the Regex. Returns the specified groups as the key and value as aPCollection.- Parameters:
pattern- The regular expression to runkeyGroupName- The Regex group name to use as the keyvalueGroupName- The Regex group name to use the value
-
replaceAll
Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces all matches with the replacement String. Returns the group as aPCollection.- Parameters:
regex- The regular expression to runreplacement- The string to be substituted for each match
-
replaceAll
Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces all matches with the replacement String. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to runreplacement- The string to be substituted for each match
-
replaceFirst
Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces the first match with the replacement String. Returns the group as aPCollection.- Parameters:
regex- The regular expression to runreplacement- The string to be substituted for each match
-
replaceFirst
Returns aRegex.ReplaceAllPTransformthat checks if a portion of the line matches the Regex and replaces the first match with the replacement String. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to runreplacement- The string to be substituted for each match
-
split
Returns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item. It will not output empty items. Returns the group as aPCollection. aPCollection.- Parameters:
regex- The regular expression to run
-
split
Returns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item. It will not output empty items. Returns the group as aPCollection. aPCollection.- Parameters:
pattern- The regular expression to run
-
split
Returns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item. Returns the group as aPCollection.- Parameters:
regex- The regular expression to runoutputEmpty- Should empty be output. True to output empties and false if not.
-
split
Returns aRegex.SplitPTransformthat splits a string on the regular expression and then outputs each item. Returns the group as aPCollection.- Parameters:
pattern- The regular expression to runoutputEmpty- Should empty be output. True to output empties and false if not.
-