It would save tremendous coding effort by allowing an exclusion list.
recase(string, [mode], flags[, exclusion])
Currently, we apply casing to all words.
What if we wish to apply Title mode except some words such as SQL, ASP, PC, UK, and USA.
eg, recase($string, "title", 1, "SQL|ASP|PC|UK|USA")
recase(string, [mode], flags)
Re: recase(string, [mode], flags)
I have nothing against that wish but I can't say that this is a "tremendous effort"...
I'd wish we'd have a better inbuild regex engine... Then something like this would be possible (and a lot faster):
Code: Select all
$string = "We need to get SQL as our primary Database";
$string = replacelist(recase($string, "l"), "SQL|ASP|PC|UK|USA", "SQL|ASP|PC|UK|USA", "|", 0 , 1);
text $string;
Code: Select all
$string = "We need to get SQL as our primary Database";
$string = regexreplace(recase($string, "l"), "\b(SQL|ASP|PC|UK|USA)\b", "\U$1");
text $string;
One of my scripts helped you out? Please donate via Paypal
Re: recase(string, [mode], flags)
I recommend using scope=1 in that replacelist:
Code: Select all
$string = "Dear NATO, the USA needs to get SQL as our primary Database from the UK, ASAP! Good luck and raspberries.";
$keepCaps = "NATO|ASAP|SQL|ASP|PC|UK|USA";
$title = recase($string, 'title');
$aString = replacelist($title, $keepCaps, $keepCaps, '|', 0, 0);
$bString = replacelist($title, $keepCaps, $keepCaps, '|', 0, 1);
text <<<>>>
Original:
$string
Title:
$title
Scope = 0:
$aString
Scope = 1:
$bString
>>>;
Results wrote:Original:
Dear NATO, the USA needs to get SQL as our primary Database from the UK, ASAP! Good luck and raspberries.
Title:
Dear Nato, The Usa Needs To Get Sql As Our Primary Database From The Uk, Asap! Good Luck And Raspberries.
Scope = 0:
Dear NATO, The USA Needs To Get SQL As Our Primary Database From The UK, ASAP! Good Luck And RASPberries.
Scope = 1:
Dear NATO, The USA Needs To Get SQL As Our Primary Database From The UK, ASAP! Good Luck And Raspberries.
Re: recase(string, [mode], flags)
Hm - if string contains 'All usable in USA'?
To me it seems a bit hard to optimize all this.
To me it seems a bit hard to optimize all this.
Win11 Pro 223H2 Gerrman
Re: recase(string, [mode], flags)
the scope = 1 flag takes care of thisif string contains 'All usable in USA'?
One of my scripts helped you out? Please donate via Paypal
Re: recase(string, [mode], flags)
But you're on your own when it comes to detecting the acronym/initialism that is also a real word: "Does that asp know ASP?"
Re: recase(string, [mode], flags)
Oh - should have read documentation first!highend wrote:the scope = 1 flag takes care of thisif string contains 'All usable in USA'?
I misinterpreted 1 as first (occurence). Didn't remember that "whole word" is possible. So correct: this is OK for a lot of situations. (For the rest: see reply of TheQwerty.) But much better than I thought...
Win11 Pro 223H2 Gerrman
Re: recase(string, [mode], flags)
Thank all XYS gurus here for your merry and exciting exchange.
I didn't know the existence of the überfunction replacelist().
I'm fond of TheQwerty's diplomat cable-like example, "Dear NATO, the USA needs to get SQL as our primary Database from the UK...".
The replacelist() should meet 99.99% acronym needs.
As result, I have no more burning desire for an enhanced recase().
It would be nice if Don's regex engine supports the case conversion for backreferenced/captured group.
Thank you for your rapid help.
I didn't know the existence of the überfunction replacelist().
I'm fond of TheQwerty's diplomat cable-like example, "Dear NATO, the USA needs to get SQL as our primary Database from the UK...".
The replacelist() should meet 99.99% acronym needs.
As result, I have no more burning desire for an enhanced recase().
It would be nice if Don's regex engine supports the case conversion for backreferenced/captured group.
Thank you for your rapid help.