DeepsetRegexParser
Extract text from a string or chat message using a regular expression pattern.
This component is deprecated. Use RegexTextExtractor from Haystack instead. Existing pipelines that use this component continue to work for now.
Key Features
- Extracts text using a regex pattern with capture groups.
- Accepts plain strings or lists of
ChatMessageobjects as input. - Can search all messages or only the last message in a chat history.
- Supports returning a single match or all matches.
Configuration
- Drag the
DeepsetRegexParsercomponent onto the canvas from the Component Library. - Click the component to open the configuration panel.
- Enter the
regex_patternwith at least one capture group to extract the desired text. - Configure
consider_all_messages,return_all_matches, andreturn_empty_on_no_matchas needed.
Connections
DeepsetRegexParser accepts text_or_messages as input — either a string or a list of chat messages. It outputs captured_text for a single match or captured_texts for multiple matches.
Connect a Generator or chat component to the input. Connect the output to components that need the extracted value, such as DeepsetGitHubIssueViewer.
Usage Example
This example extracts a URL from a chat message:
components:
regex_parser:
type: deepset_cloud_custom_nodes.parsers.regex_parser.DeepsetRegexParser
init_parameters:
regex_pattern: '<issue url="(.+)">'
consider_all_messages: false
return_empty_on_no_match: false
return_all_matches: false
inputs:
text_or_messages:
- regex_parser.text_or_messages
outputs:
captured_text: regex_parser.captured_text
Parameters
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| text_or_messages | str or List[ChatMessage] | Text or chat messages to search. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| captured_text | str | First captured text when return_all_matches is False. | |
| captured_texts | List[str] | All captured texts when return_all_matches is True. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| regex_pattern | str | Regular expression pattern with a capture group to extract text. | |
| consider_all_messages | bool | False | If True, applies the regex to all chat messages. If False, only the last message is searched. |
| return_empty_on_no_match | bool | False | If True, returns an empty dictionary when no match is found. |
| return_all_matches | bool | False | If True, returns all matches as captured_texts. If False, returns only the first match as captured_text. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| text_or_messages | str or List[ChatMessage] | Text or chat messages to search. |
Was this page helpful?