I have some strings in the following formats:
this is a string
This is a string
This is a (string)
This is a string
and i want a regex convert it to the following:
this_is_a_string
with no leading
I have the following using preg_replace which is getting me almost all of the way:
preg_replace('/[^A-Za-z]+/', '_', $string)
However, it converts the last ) to an underscore which is not acceptable for my uses. I could easily trim that off in a separate function but im wondering if its possible to do with a single regex?