I'm not sure if this is possible using Regex but I'd like to be able to limit the number of underscores allowed based on a different character. This is to limit crazy wildcard queries to a search engine written in Java.

The starting characters would be alphanumeric. But I basically want a match if there are more underscores than preceding characters. So

BA\_ would be fine but BA\_\_\_ would match the regex and would get kicked out of the query parser.

Is that possible using Regex?