sdk
sdk copied to clipboard
feat: Add regex parsing support within stream maps
Would be helpful to have a regex function added to the supported inline stream map functions.
The use case I am looking for is that I could provide a regex search criteria and return a list of results. Given the sample text for a stream property called comment_body:
@person1 - This is a test comment. Wanted to talk with you and @person3 about this really cool topic.
cc @person3
fyi @person4
The declared function might be regex_findmany(from_text: str, search_pattern: str) -> list[str].
Sample usage patterns
String output:
"mentioned_persons": "', '.join(regex_findmany(comment_body, "@\S*"))'"
Would generate:
"mentioned_persons": "@person1, @person2, @person3, @person4"
Boolean output (specific item):
"mentioned_aj": "bool('@aaronsteers' in regex_findmany(comment_body, "@\S*"))"
Would generate:
"mentioned_aj": true
Boolean output (any match):
"mentioned_anyone": "bool(true if regex_findmany(comment_body, "@\S*") else false)"
Would generate:
"mentioned_anyone": true
This is especially helpful when the original text is sensitive or confidential. We want to extract specific tokens from the text but we don't want to extract the full text itself.