# Converting REGEX to BNF grammar

Say I have a bunch of regex expressions which are used as filtering rules. (Any special extraction capabilities are unnecessary here, the set of regular expressions I have is only used for filtering down sentences).

Can any pure regex be converted into BNF? (ABNF, EBNF, etc.)

Are there well known algorithms (or existing library implementations) that can perform the conversion?

The language I wish to convert from is actually not the standard language of regular expressions, but one that conditions on word taggings which are provided per word (part-of-speech tags that come along with the text). So it is a variant of regular expressions, which operates at the word level rather than the character level.

Thanks!

It depends on your type of regular expressions. Classical regular expressions describe regular languages, whereas BNFs describe context-free languages. Since regular languages are context-free, you can convert every regular expression to a BNF. This is covered in courses on automata theory. There are three steps: convert your regular expression to an $\epsilon$-NFA, then convert the $\epsilon$-NFA to an NFA, then convert the NFA to a regular grammar.