First off, I don't think Low Replace supports multiple="yes"
for regex replacements. Considering the complexities allowed in regex expressions, it would be a difficult task indeed to allow Replace A|B|C with X|Y|Z type regex searches when each of A|B|C are individual regex searches.
I also don't see any Low Replace functionality to do the replace with case transforms. In straight regex it's pretty simple: prefix your replacement with \U
(or something very similar, depending on your regex flavor), but Low's only implementing a regex subset, it seems. No matter the syntax I tried, I was not able to get the replacement to change case. Of course, I could be missing something obvious, wouldn't be the first time (see some of my questions here on the Stacks. ;-) If the resulting text does not actually have to BE uppercase, but can rather just look uppercase, then how about a little CSS text-transform:uppercase
?
So, we're left with the basic replacement of spaces to underscores. That's achievable with
{exp:low_replace find="([\w\W+]) +" replace="$1_" regex="yes"}
Lorem ipsum dolor sit amet. Nearly.
{/exp:low_replace}
You will note that the search is for both alpha-numeric characters (\w
) as well as non-alpha-numerics (\W
). This is to factor for the possibilities of commas, periods, etc. If you know that your case will never encounter these, you can leave the statement as
{exp:low_replace find="(\w+) +" replace="$1_" regex="yes"}
Lorem ipsum dolor sit amet. Nearly.
{/exp:low_replace}
The first statement results in
Lorem_ipsum_dolor_sit_amet._Nearly.
The second statement results in
Lorem_ipsum_dolor_sit_amet. Nearly.
(note the missing underscore before 'Nearly.')
Now, for what it's worth, there's a utility by Causing Effect by the name of CE String that just completely kicks ninja string manipulation arse. For $10 it's a Bat Utility Belt of string manipulation the likes of which are endlessly joyous for a nerd. Worth a look. The beauty of it is that you can pile up your manipulations, so, say, do your regex search/replace, then UPPERCASE the whole thing.
FYI.