RegExtract
Description
Extracts text from a field that matches the pattern of the regular expression entered. A new column is created for the results. (List)
Hero Platform_'s RegExtract uses RE2 Syntax for regular expressions.
For more support on writing regular expressions, contact a support representative.
Use
- Argument:
- Select an argument. (String)
- RegEx:
- Enter an output field name.
- Output field name:
- Enter a regular expression to apply to the argument's value.
Examples
File Extensions
In this example, the text strings contain a file name. The user wants to extract the file extension.
(Note: There can be multiple regular expressions to accomplish the same outcome.)
Example Field String | Regular expression value | Result |
---|---|---|
img000.jpg | .[0-9a-zA-Z]+$ | [.jpg] |
img000.JPEG | .[0-9a-zA-Z]+$ | [.JPEG] |
img000.jpg | (?i)\.[0-9a-z]+$ | [.jpg] |
img000.JPEG | (?i)\.[0-9a-z]+$ | [.JPEG] |
Hashtags
In this example, the text strings come from Twitter. The user wants to extract all the hashtag words from the text.
Example Field String | Regular expression value | Result |
---|---|---|
If you're looking to implement any #ArtificialIntelligence project, check out our step-by-step guide. #AI | #[a-zA-Z]+ | [#ArtificialIntelligence, #AI] |
Hero Platform_ Example
An example of this function can be found in Hero Platform_'s library of examples.
Download the example titled "function_RegExtract" to see an example of this function.