Jump to content

Propercase & Uppercase


TheSaint
 Share

Recommended Posts

These are just my simple improvements to Propercase & Uppercase ... my take on them.

Obviously you need to set $props = 1 before calling the functions, for the extra replacements to work.

I use this code or similar, in many of my programs, and thought others may like some pre-made code to save them the trouble.

ProperCase could probably be renamed to TitleCase.

Func ProperCase($txt)
    $txt = _StringProper($txt)
    If $props = 1 Then
        ; Basics
        $txt = StringReplace($txt, "'D", "'d", 0, 1)
        $txt = StringReplace($txt, "'L", "'l", 0, 1)
        $txt = StringReplace($txt, "'M", "'m", 0, 1)
        $txt = StringReplace($txt, "'N", "'n", 0, 1)
        $txt = StringReplace($txt, "'R", "'r", 0, 1)
        $txt = StringReplace($txt, "'S", "'s", 0, 1)
        $txt = StringReplace($txt, "'T", "'t", 0, 1)
        $txt = StringReplace($txt, "'V", "'v", 0, 1)
        ; Roman Numerals
        ; Higher number of letters must come first (i.e. III before II before I)
        ; so that replacements occur in right order
        $txt = StringReplace($txt, "Iii", "III", 0, 1)
        $txt = StringReplace($txt, "Ii", "II", 0, 1)
        $txt = FixRomanNumerals($txt, "Iv")
        $txt = StringReplace($txt, "Viii", "VIII", 0, 1)
        $txt = StringReplace($txt, "Vii", "VII", 0, 1)
        $txt = FixRomanNumerals($txt, "Vi")
        $txt = FixRomanNumerals($txt, "Ix")
        $txt = StringReplace($txt, "Xiii", "XIII", 0, 1)
        $txt = StringReplace($txt, "Xii", "XII", 0, 1)
        $txt = FixRomanNumerals($txt, "Xi")
        $txt = FixRomanNumerals($txt, "Xiv")
        $txt = StringReplace($txt, "Xviii", "XVIII", 0, 1)
        $txt = StringReplace($txt, "Xvii", "XVII", 0, 1)
        $txt = FixRomanNumerals($txt, "Xvi")
        $txt = FixRomanNumerals($txt, "Xv")
        $txt = FixRomanNumerals($txt, "Xix")
        $txt = StringReplace($txt, "Xxiii", "XXIII", 0, 1)
        $txt = StringReplace($txt, "Xxii", "XXII", 0, 1)
        $txt = StringReplace($txt, "Xxiv", "XXIV", 0, 1)
        $txt = StringReplace($txt, "Xxix", "XXIX", 0, 1)
        $txt = StringReplace($txt, "Xxi", "XXI", 0, 1)
        $txt = StringReplace($txt, "Xxviii", "XXVIII", 0, 1)
        $txt = StringReplace($txt, "Xxvii", "XXVII", 0, 1)
        $txt = StringReplace($txt, "Xxvi", "XXVI", 0, 1)
        $txt = StringReplace($txt, "Xxv", "XXV", 0, 1)
        $txt = StringReplace($txt, "Xxx", "XXX", 0, 1)
        $txt = StringReplace($txt, "Xx", "XX", 0, 1)
        ; Numbers
        $txt = StringReplace($txt, "1St", "1st", 0, 1)
        $txt = StringReplace($txt, "2Nd", "2nd", 0, 1)
        $txt = StringReplace($txt, "3Rd", "3rd", 0, 1)
        $txt = StringReplace($txt, "4Th", "4th", 0, 1)
        $txt = StringReplace($txt, "5Th", "5th", 0, 1)
        $txt = StringReplace($txt, "6Th", "6th", 0, 1)
        $txt = StringReplace($txt, "7Th", "7th", 0, 1)
        $txt = StringReplace($txt, "8Th", "8th", 0, 1)
        $txt = StringReplace($txt, "9Th", "9th", 0, 1)
        $txt = StringReplace($txt, "0Th", "0th", 0, 1)
       ; Others
        $txt = StringReplace($txt, " Cd ", " CD ", 0, 1)
        If StringLeft($txt, 3) = "Cd " Then $txt = "CD" & StringTrimLeft($txt, 2)
        If StringRight($txt, 3) = " Cd" Then $txt = StringTrimRight($txt, 2) & "CD"
        ;
        ; Mc's & O's
        $z = "a"
        While 1
            $txt = StringReplace($txt, "Mc" & $z, "Mc" & StringUpper($z), 0, 1)
            $txt = StringReplace($txt, "O'" & $z, "O'" & StringUpper($z), 0, 1)
            $z = Chr(Asc($z) + 1)
            If $z = "{" Then ExitLoop
        WEnd
    EndIf
    Return $txt
EndFunc ;=> ProperCase

Func FixRomanNumerals($txt, $rom)
    $txt = StringReplace($txt, "(" & $rom & ")", "(" & StringUpper($rom) & ")", 0, 1)
     $txt = StringReplace($txt, " " & $rom & " ", " " & StringUpper($rom) & " ", 0, 1)
    $len = StringLen($rom)
    If StringLeft($txt, $len + 1) = $rom & " " Then $txt = StringUpper($rom) & StringTrimLeft($txt, $len)
    If StringRight($txt, $len + 1) = " " & $rom Then $txt = StringTrimRight($txt, $len) & StringUpper($rom)
   Return $txt
EndFunc ;=> FixRomanNumerals

If you are not sure why these replacements are needed, try _StringProper with words like I'd, I'll, Don't, I've, Mark II, McCartney, etc, and McCartney with StringUpper (though some might like it all capitals).

Rightly speaking, you'd probably incorporate the $props value as an extra parameter if you were making a UDF for these 2 functions.

I'm sure there are some other replacements that I've missed, that people are quite welcome to mention here, while some like 'Mark IV' or similar, are more complex to cater for and require 3 statements (1 x Replace, 1 x StringLeft, 1 x StringRight), so I haven't included many of those here, but you can add them yourself. When determining what replacements are acceptable, I've had to go for a 99% case scenario on occasion ... but obviously, there will be some occasions where a replacement may be wrong (hence the $props switch).

Please also see this topic, as a place to mention any other issues with Propercase and Uppercase ... I'd also like to see a SentenceCase function be developed (Anybody?) ... and maybe an OddEvenCase (what for, who knows).

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I've just updated the code, etc in first post ... it's amazing what your mind will overlook late at night (i.e. older code and older thinking) ... when you should have been in bed hours before. Then after a good sleep, you suddenly become aware that you said or did something stupid or irrational the night before (and it's been cogitating in your mind all night ... probably because you subconsciously knew something wasn't quite right).

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Ok, I've added a few more elements to bring Roman Numerals up to 25, etc.

I also re-fixed the order of Roman Numeral replacements, which in my befuddled state to night I'd changed (because I didn't twig to why I had it that way in the first place, so I mistakenly thought I'd correct it) ... lesson to self here (am I listening ... probably not) ... don't get involved with code after being up late after a party ... dumkopf! :D

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

The Saint -

You ought to put something in for " O'" to handle the O'Donalds, O'Hara's, O'Malley's, etc.

Good Idea, and done with one line (included in code above).

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Ok, in an effort to be even more complete like, I've increased support for Roman Numerals to number 30, and reduced the lines of code by implementing a FixRomanNumerals function ... which will also make it easier to add more numerals later (but probably not by me). ;)

I hadn't originally intended to keep working on this, but like always, when my code get's put out there, I keep thinking about it ... unlike usual, where I keep moving on to something else ... usually it get's put in the I'm gunna add other things or improvements later basket ... where it tends to stay and fades into oblivion eventually ... unfortunately. ^_^

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • 3 weeks later...

I haven't got the time or inclination at present, but the space tests used above, should probably be updated to a test for a non-alpha character, to be truly perfect.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Ok, in an effort to be even more complete like, I've increased support for Roman Numerals to number 30, and reduced the lines of code by implementing a FixRomanNumerals function ... which will also make it easier to add more numerals later (but probably not by me). ;)

I hadn't originally intended to keep working on this, but like always, when my code get's put out there, I keep thinking about it ... unlike usual, where I keep moving on to something else ... usually it get's put in the I'm gunna add other things or improvements later basket ... where it tends to stay and fades into oblivion eventually ... unfortunately. ^_^

Since I know you love RegExp and have been secretly yearning for someone to help cut down on the code and include all the Roman Numeral combos I humbly submit this, for what it's worth:

Func _IsRomanNumeral($sWord)
;http://thehazeltree.org/diveintopython/7.html "Example 7.8. Validating Roman Numerals with {n,m}"
    $validRN = "^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$"
    If StringRegExp($sWord, $validRN) Then
        Return True
    Else
        Return False
    EndIf
EndFunc  ;==>_IsRomanNumeral
:(
Link to comment
Share on other sites

Since I know you love RegExp and have been secretly yearning for someone to help cut down on the code and include all the Roman Numeral combos I humbly submit this, for what it's worth:

:D

Oh you love to tease! :(

It looks lovingly compacted, so I better give it a whirl soon I suppose ... though I note that it is missing code to separate out words ... not to mention working with brackets, etc ... so not quite as compact as it first seems ... not that I'm complaining mind. :D

And just in case people get the impression that I don't like or even know how to use RegExp, let me just say that I do use it occasionally, and it is a wonderful function ... but let's just say, that I mostly prefer to do my mind-bending (or is that stressing) in other ways ... that's why my mantra is 'Simple Is Best' ... I sleep easier that way ... and most people think I'm normal ... well, to some degree anyway. ;)

Oops! I forgot to say thanks! ^_^

Thanks! :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Func _IsRomanNumeral($sWord)
If StringRegExp($sWord, "^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") Then Return True
Return False
EndFunc ;==>_IsRomanNumeral

Link to comment
Share on other sites

weaponx

Is it just shorter version? ^_^ Then this can be even shorter:

Func _IsRomanNumeral($sWord)
    Return StringRegExp($sWord, "^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") = 1
EndFunc

;)

P.S

Nice regexp ResNullius.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Oh what a bunch of clever dicks! :)

I also forgot to add, that only true or false is returned, so you then need more code to act upon that return, and then also rebuild if the total source text is more than one word ... so while I don't deny the cleverness of all, the code required to do the complete job is not as compacted as seemingly portrayed. :idea:

Am I the only one who believes that reduction of code, is not always a good or necessary thing ... there is such a thing as readability and ease of troubleshooting too. Mind you if someone puts it all into a UDF, then who am I to complain ... if it works, then I'm happy. :party:

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Oh what a bunch of clever dicks! :)

I also forgot to add, that only true or false is returned, so you then need more code to act upon that return, and then also rebuild if the total source text is more than one word ... so while I don't deny the cleverness of all, the code required to do the complete job is not as compacted as seemingly portrayed. :idea:

Am I the only one who believes that reduction of code, is not always a good or necessary thing ... there is such a thing as readability and ease of troubleshooting too. Mind you if someone puts it all into a UDF, then who am I to complain ... if it works, then I'm happy. :party:

$test = "Vii, IIv, ic, f, x, IXC"
$atest = StringSplit($test, ", ", 2 + 1)
For $i = 0 To UBound($atest) - 1
    MsgBox(0, "", $atest[$i] & " = " & _UpperCaseRomanNumeral($atest[$i]))
Next

Func _UpperCaseRomanNumeral($sWord)
    If StringRegExp($sWord, "(?i)^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") Then $sWord = StringUpper($sWord)
    Return $sWord
EndFunc  ;==>_UpperCaseRomanNumeral
:P
Link to comment
Share on other sites

$test = "Vii, IIv, ic, f, x, IXC"
 $atest = StringSplit($test, ", ", 2 + 1)
 For $i = 0 To UBound($atest) - 1
     MsgBox(0, "", $atest[$i] & " = " & _UpperCaseRomanNumeral($atest[$i]))
 Next
 
 Func _UpperCaseRomanNumeral($sWord)
     If StringRegExp($sWord, "(?i)^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") Then $sWord = StringUpper($sWord)
     Return $sWord
 EndFunc ;==>_UpperCaseRomanNumeral
:party:
Well, I thought it looked impressive, but it just returns the same text ... nothing is changed to uppercase. :idea:

And I'm getting a headache just thinking about troubleshooting your code ... let alone doing it! :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Well, I thought it looked impressive, but it just returns the same text ... nothing is changed to uppercase. :party:

And I'm getting a headache just thinking about troubleshooting your code ... let alone doing it! :)

Running the sample, you should see "Vii", "x", and "IXC" returned as upper case: "Vii" and "x" because they are legitimate Roman Numerals, and ""IXC" because it isn't legit, but was uppercase to start with.

Maybe this will make it more clear:

$test = "Vii, IIv, ic, f, x, IXC"
$atest = StringSplit($test, ", ", 2 + 1)
For $i = 0 To UBound($atest) - 1
         MsgBox(0, "", "Original string: " & $atest[$i] & @CRLF & "Uppercased: " & _UpperCaseRomanNumeral($atest[$i]) & " (if RN or passed as Upper)") 
Next

Func _UpperCaseRomanNumeral($sWord)
     If StringRegExp($sWord, "(?i)^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") Then $sWord = StringUpper($sWord)
     Return $sWord
EndFunc;==>_UpperCaseRomanNumeral
Link to comment
Share on other sites

Running the sample, you should see "Vii", "x", and "IXC" returned as upper case: "Vii" and "x" because they are legitimate Roman Numerals, and ""IXC" because it isn't legit, but was uppercase to start with.

Maybe this will make it more clear:

$test = "Vii, IIv, ic, f, x, IXC"
 $atest = StringSplit($test, ", ", 2 + 1)
 For $i = 0 To UBound($atest) - 1
          MsgBox(0, "", "Original string: " & $atest[$i] & @CRLF & "Uppercased: " & _UpperCaseRomanNumeral($atest[$i]) & " (if RN or passed as Upper)") 
 Next
 
 Func _UpperCaseRomanNumeral($sWord)
      If StringRegExp($sWord, "(?i)^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") Then $sWord = StringUpper($sWord)
      Return $sWord
 EndFunc;==>_UpperCaseRomanNumeral
Well, I don't know if your test showed the same as mine, but all I got was a Msgbox with something like - "Vii, IIv, ic, f, x, IXC" = "Vii, IIv, ic, f, x, IXC"

In other words, no change! :P

With your new code, I get 2 Msgboxes, but the second is still essentially the same result ... even though it says they should be uppercase, none of them except IXC are. :party:

I just had a thought ... :D

Now I'm getting somewhere ... just switched to AutoIt v3.3.0.0 (was using 3.2.4.9). Now I'm getting a Msgbox for each character (rather than all displayed in one), and some are uppercase and some aren't (as to be expected). :P

Very Good! :D

Now I can test it properly! :D

You should start a sub-group here called The Minimalists ... I can already think of a few who'd most likely join. Of course, the rest of us will just probably call you The Clever Dicks ... but hey, nothing wrong with that! ;)

I knew the arrangement with Includes was different with later versions of AutoIt, but I hadn't realized it was that fundamentally different without. :idea:

Thanks for your input ... you clever dick you! :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Ok, just for fun, I decided to replace the 'Basics' section

; Basics
        $txt = StringReplace($txt, "'D", "'d", 0, 1)
        $txt = StringReplace($txt, "'L", "'l", 0, 1)
        $txt = StringReplace($txt, "'M", "'m", 0, 1)
        $txt = StringReplace($txt, "'N", "'n", 0, 1)
        $txt = StringReplace($txt, "'R", "'r", 0, 1)
        $txt = StringReplace($txt, "'S", "'s", 0, 1)
        $txt = StringReplace($txt, "'T", "'t", 0, 1)
        $txt = StringReplace($txt, "'V", "'v", 0, 1)oÝ÷ Û­Ê&zh§f¥Ëmʡ׺Ú"µÍ  ÌÍØÈHÝ[ÔÜ]
    ][ÝÉÌÎNÑ   ÌÎNÙ ÌÎNÓ ÌÎNÛ ÌÎNÓ_    ÌÎNÛ_    ÌÎNÓ ÌÎNÛ ÌÎNÔ ÌÎNÜ ÌÎNÔß   ÌÎNÜß   ÌÎNÕ ÌÎNÝ ÌÎNÕ ÌÎNÝ][ÝË   ][Ýß  ][ÝÊBÜ   ÌÍÚHHHÈ ÌÍØÖÌHHHÝ ÌÍÝHÝ[ÔXÙJ    ÌÍÝ  ÌÍØÖÉÌÍÚWK  ÌÍØÖÉÌÍÚH
ÈWKJB^oÝ÷ Ûbr"Zk¡¶)ëayÉ^½êÝÉ,jX­¶W¡jbz¶î¶Ø^Ë¥ËbZk¡¶'(Zv¢ëfzz-ºÈ§´­®)àEèÆÛ¢¶Ò¶¸§ QzZqïÛw_¢»azw°n'¬êÞj·­Â-êæzØhvËaj×hm±«Þ¢w(uæî¶ÈhºW[yæ¬êí¢éÝz»-jwZºÚ"µÍ   ÌÍÝHH    ][ÝÉÌÎNÑ   ][Ý  ÌÍÛH ][ÝÉÌÎNÙ   ][ÝÂÚ[HB ÌÍÝHÝ[ÔXÙJ    ÌÍÝ  ÌÍÝK ÌÍÛJBY   ÌÍÝHH    ][ÝÉÌÎNÑ   ][ÝÈ[ ÌÍÝHH    ][ÝÉÌÎNÓ   ][Ý  ÌÍÛH ][ÝÉÌÎNÛ   ][ÝÂ[ÙRY ÌÍÝHH    ][ÝÉÌÎNÓ   ][ÝÈ[ ÌÍÝHH    ][ÝÉÌÎNÓI][Ý    ÌÍÛH ][ÝÉÌÎNÛI][ÝÂ[ÙRY   ÌÍÝHH    ][ÝÉÌÎNÓI][ÝÈ[   ÌÍÝHH    ][ÝÉÌÎNÓ][Ý ÌÍÛH ][ÝÉÌÎNÛ][ÝÂ[ÙRY    ÌÍÝHH    ][ÝÉÌÎNÓ][ÝÈ[    ÌÍÝHH    ][ÝÉÌÎNÔ][Ý ÌÍÛH ][ÝÉÌÎNÜ][ÝÂ[ÙRY    ÌÍÝHH    ][ÝÉÌÎNÔ][ÝÈ[    ÌÍÝHH    ][ÝÉÌÎNÔÉ][Ý   ÌÍÛH ][ÝÉÌÎNÜÉ][ÝÂ[ÙRY  ÌÍÝHH    ][ÝÉÌÎNÔÉ][ÝÈ[  ÌÍÝHH    ][ÝÉÌÎNÕ   ][Ý  ÌÍÛH ][ÝÉÌÎNÝ   ][ÝÂ[ÙRY ÌÍÝHH    ][ÝÉÌÎNÕ   ][ÝÈ[ ÌÍÝHH    ][ÝÉÌÎNÕ][Ý ÌÍÛH ][ÝÉÌÎNÝ][ÝÂ[ÙRY    ÌÍÝHH    ][ÝÉÌÎNÕ][ÝÈ[^]ÛÜ[YÑ[oÝ÷ Ù©Ýjëh×6        $u = "'D"
        $l = "'d"
        While 1
            $txt = StringReplace($txt, $u, $l, 0, 1)
            Select
            Case $u = "'D"
                $u = "'L"
                $l = "'l"
            Case $u = "'L"
                $u = "'M"
                $l = "'m"
            Case $u = "'M"
                $u = "'N"
                $l = "'n"
            Case $u = "'N"
                $u = "'R"
                $l = "'r"
            Case $u = "'R"
                $u = "'S"
                $l = "'s"
            Case $u = "'S"
                $u = "'T"
                $l = "'t"
            Case $u = "'T"
                $u = "'V"
                $l = "'v"
            Case $u = "'V"
                ExitLoop
            Case Else
            EndSelect
        WEnd

Don't forget to set the Globals or Dims ($u, $l, $c, $i, $txt), and remember that the 'Basics' section in the first post, is replaced by each of these methods.

You can try it with text like I'll, I've, I'm, don't, The Saint's Toolbox, etc.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Now I'm getting somewhere ... just switched to AutoIt v3.3.0.0 (was using 3.2.4.9)

3.2.4.9??? That is so like May 2007 man!

You should start a sub-group here called The Minimalists ... I can already think of a few who'd most likely join. Of course, the rest of us will just probably call you The Clever Dicks ... but hey, nothing wrong with that! :)

Nothing wrong at all!

But it really isn't so much about minimalism as it is about making the code do the work.

I'll agree that RegExp can be hard to maintain when you go back to look at it sometimes, but proper commenting (as with any code really) can be a big help.

I also like the info given on the page I linked to (http://thehazeltree.org/diveintopython/7.html) where this RegExp came from. The author steps through it all quite logically.

I don't consider myself a RegExp expert by any means: I just try different things until I get the result I want, or in this case: pilfer from someone who's already done the work. :party:

I was actually using this in my own RegExp based ProperCase function (which I might post sometime) but thought I'd slip it in here if you wanted to use it.

Cheers,

ResNullius, member CDPG (clever dicks programming group)

Edited by ResNullius
Link to comment
Share on other sites

3.2.4.9??? That is so like May 2007 man!

Nothing wrong at all!

But it really isn't so much about minimalism as it is about making the code do the work.

I'll agree that RegExp can be hard to maintain when you go back to look at it sometimes, but proper commenting (as with any code really) can be a big help.

I also like the info given on the page I linked to (http://thehazeltree.org/diveintopython/7.html) where this RegExp came from. The author steps through it all quite logically.

I don't consider myself a RegExp expert by any means: I just try different things until I get the result I want, or in this case: pilfer from someone who's already done the work. :P

I was actually using this in my own RegExp based ProperCase function (which I might post sometime) but thought I'd slip it in here if you wanted to use it.

Cheers,

ResNullius, member CDPG (clever dicks programming group)

Yeah, I'm stuck in the past most of the time.

I suppose I should read that page you linked to ... though I might have a couple of loosening beers first. :idea:

And no worries, thanks for sharing!

I suppose I should edit the code in the first post some time ... though I have grown attached to it's simplicity! :party:

I might start a group called the Code Users Simple Simon Editing Department (CUSSED). :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

ResNullius, member CDPG (clever dicks programming group)

I WANT TO JOIN! Are you the founding member? Is there a constitution etc.? When's the AGM?

Someone once suggested to me that we could measure productivity of developers by the number of lines of code that they write. I pointed out that this was just going to reward people for writing bloated code. I'm always looking for optimisations and doing stuff in the fewest possible lines.

WBD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...