Regexer is a Python Regex pattern generator.
Curious? Try it now here!
Under the hood, it uses LLM (OpenAI or Anthropic) to generate a Regex pattern based on a given example.
-
Input: Accepts a CSV string with only 2 headers,
base_string
andsearch_string
. Wherebase_string
contains the string wheresearch_string
must be extracted from. -
CSV Validator: LLM will validate if the given CSV string follows the correct format. Instructions will be provided if input fails the validation.
-
LLM will create a Regex pattern based on the input CSV
-
Regex Validator: validates the Regex pattern by comparing its output against
search_string
. If for each row the Regex pattern correctly outputs thesearch_string
. The program will terminate and the pattern will be displayed. -
If Regex Validator fails, LLM will retry
max_retries
number of times until Regex Validator is passed. Ifmax_retries
is exhausted, the last pattern will be displayed.
Use the CSV string below as an example.
base_string,search_string
"https://docs.google.com/spreadsheets/d/aabc-d12/edit#gid=0","aabc-d12"
"https://docs.google.com/spreadsheets/d/33_eed/33_eed","33_eed"