Package org.apache.beam.sdk.transforms
Class Regex
java.lang.Object
org.apache.beam.sdk.transforms.Regex
PTransform
s 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 class
Regex.MatchesName<String>
takes aPCollection<String>
and returns aPCollection<List<String>>
representing the value extracted from all the Regex groups of the inputPCollection
to the number of times that element occurs in the input.static class
Regex.Find<String>
takes aPCollection<String>
and returns aPCollection<String>
representing the value extracted from the Regex groups of the inputPCollection
to the number of times that element occurs in the input.static class
Regex.Find<String>
takes aPCollection<String>
and returns aPCollection<List<String>>
representing the value extracted from the Regex groups of the inputPCollection
to the number of times that element occurs in the input.static class
Regex.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 inputPCollection
to the number of times that element occurs in the input.static class
Regex.Find<String>
takes aPCollection<String>
and returns aPCollection<String>
representing the value extracted from the Regex groups of the inputPCollection
to the number of times that element occurs in the input.static class
Regex.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 inputPCollection
to the number of times that element occurs in the input.static class
Regex.Matches<String>
takes aPCollection<String>
and returns aPCollection<String>
representing the value extracted from the Regex groups of the inputPCollection
to the number of times that element occurs in the input.static class
Regex.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 inputPCollection
to the number of times that element occurs in the input.static class
Regex.MatchesName<String>
takes aPCollection<String>
and returns aPCollection<String>
representing the value extracted from the Regex groups of the inputPCollection
to the number of times that element occurs in the input.static class
Regex.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 inputPCollection
to the number of times that element occurs in the input.static class
Regex.ReplaceAll<String>
takes aPCollection<String>
and returns aPCollection<String>
with all Strings that matched the Regex being replaced with the replacement string.static class
Regex.ReplaceFirst<String>
takes aPCollection<String>
and returns aPCollection<String>
with the first Strings that matched the Regex being replaced with the replacement string.static class
Regex.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.AllMatches
allMatches
(String regex) Returns aRegex.AllMatches
PTransform
that checks if the entire line matches the Regex.static Regex.AllMatches
allMatches
(Pattern pattern) Returns aRegex.AllMatches
PTransform
that checks if the entire line matches the Regex.static Regex.Find
Returns aRegex.Find
PTransform
that checks if a portion of the line matches the Regex.static Regex.Find
Returns aRegex.Find
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindName
Returns aRegex.FindName
PTransform
that checks if a portion of the line matches the Regex.static Regex.Find
Returns aRegex.Find
PTransform
that checks if a portion of the line matches the Regex.static Regex.Find
Returns aRegex.Find
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindName
Returns aRegex.FindName
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindAll
Returns aRegex.FindAll
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindAll
Returns aRegex.FindAll
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindKV
Returns aRegex.FindKV
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindNameKV
Returns aRegex.FindNameKV
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindKV
Returns aRegex.FindKV
PTransform
that checks if a portion of the line matches the Regex.static Regex.FindNameKV
Returns aRegex.FindNameKV
PTransform
that checks if a portion of the line matches the Regex.static Regex.Matches
Returns aRegex.Matches
PTransform
that checks if the entire line matches the Regex.static Regex.Matches
Returns aRegex.Matches
PTransform
that checks if the entire line matches the Regex.static Regex.MatchesName
Returns aRegex.MatchesName
PTransform
that checks if the entire line matches the Regex.static Regex.Matches
Returns aRegex.Matches
PTransform
that checks if the entire line matches the Regex.static Regex.Matches
Returns aRegex.Matches
PTransform
that checks if the entire line matches the Regex.static Regex.MatchesName
Returns aRegex.MatchesName
PTransform
that checks if the entire line matches the Regex.static Regex.MatchesKV
Returns aRegex.MatchesKV
PTransform
that checks if the entire line matches the Regex.static Regex.MatchesNameKV
Returns aRegex.MatchesNameKV
PTransform
that checks if the entire line matches the Regex.static Regex.MatchesKV
Returns aRegex.MatchesKV
PTransform
that checks if the entire line matches the Regex.static Regex.MatchesNameKV
Returns aRegex.MatchesNameKV
PTransform
that checks if the entire line matches the Regex.static Regex.ReplaceAll
replaceAll
(String regex, String replacement) Returns aRegex.ReplaceAll
PTransform
that checks if a portion of the line matches the Regex and replaces all matches with the replacement String.static Regex.ReplaceAll
replaceAll
(Pattern pattern, String replacement) Returns aRegex.ReplaceAll
PTransform
that checks if a portion of the line matches the Regex and replaces all matches with the replacement String.static Regex.ReplaceFirst
replaceFirst
(String regex, String replacement) Returns aRegex.ReplaceAll
PTransform
that checks if a portion of the line matches the Regex and replaces the first match with the replacement String.static Regex.ReplaceFirst
replaceFirst
(Pattern pattern, String replacement) Returns aRegex.ReplaceAll
PTransform
that checks if a portion of the line matches the Regex and replaces the first match with the replacement String.static Regex.Split
Returns aRegex.Split
PTransform
that splits a string on the regular expression and then outputs each item.static Regex.Split
Returns aRegex.Split
PTransform
that splits a string on the regular expression and then outputs each item.static Regex.Split
Returns aRegex.Split
PTransform
that splits a string on the regular expression and then outputs each item.static Regex.Split
Returns aRegex.Split
PTransform
that splits a string on the regular expression and then outputs each item.
-
Method Details
-
matches
Returns aRegex.Matches
PTransform
that 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.Matches
PTransform
that 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.Matches
PTransform
that 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.Matches
PTransform
that 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.MatchesName
PTransform
that 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.MatchesName
PTransform
that 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.AllMatches
PTransform
that 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.AllMatches
PTransform
that 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.MatchesKV
PTransform
that 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.MatchesKV
PTransform
that 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.MatchesNameKV
PTransform
that 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.MatchesNameKV
PTransform
that 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.Find
PTransform
that 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.Find
PTransform
that 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.Find
PTransform
that 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.Find
PTransform
that 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.FindName
PTransform
that 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.FindName
PTransform
that 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.FindAll
PTransform
that 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.FindAll
PTransform
that 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.FindKV
PTransform
that 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.FindKV
PTransform
that 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.FindNameKV
PTransform
that 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.FindNameKV
PTransform
that 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.ReplaceAll
PTransform
that 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.ReplaceAll
PTransform
that 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.ReplaceAll
PTransform
that 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.ReplaceAll
PTransform
that 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.Split
PTransform
that 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.Split
PTransform
that 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.Split
PTransform
that 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.Split
PTransform
that 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.
-