I have some form fields that look like this: "Yes (if "Yes", skip the next question)" and I'd like to have any labels with text inside parenthesis be wrapped in a span so they can be styled. I tried writing a preprocess but it's not doing anything.
function THEME_preprocess_form_element_label(&$variables){
$element = $variables['element'];
$title = $element['#title'];
$pat = "/\((.*?)\)/";
if (isset($title) && preg_match($pat, $title)) {
$titleSplit = preg_split($pat, $title);
$newTitle = $titleSplit[0]+"<span>"+$titleSplit[1]+"</span>";
$title = $newTitle;
}
}