1. A method for string matching, comprising: accepting an input regular expression comprising one or more nested references to respective referenced regular expressions; replacing the nested references in the input regular expression with the respective referenced regular expressions, so as to provide a modified regular expression that does not contain a reference to another regular expression; and matching the modified regular expression to a target string.