Jump to content

iCode

Active Members
  • Posts

    194
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

iCode's Achievements

  1. whoops! yes, that was obvious. thanks first post updated.
  2. This is a spin-off of >Seeker's function which i rewrote and tried to optimize for doing only sentence casing and for better Unicode handling. Haven't done a lot of testing with it, but it seems to work well so far. #include-once ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SentenceCase ; Description ...: Capitalize the first letter of sentences. ; Syntax ........: _SentenceCase(Byref $sString) ; Parameters ....: $sString: [in/out] A string value. ; Return values .: Success: A string is returned. ; Failure: Sets @error = 1 and returns 0. ; Author ........: iCode ; Modified ......: 30-MAR-2015 ; Remarks .......: ; Related .......: http://www.autoitscript.com/forum/topic/147086-udf-for-title-case-initial-caps-and-sentence-case/ ; Link ..........: http://www.autoitscript.com/forum/topic/169290-sentence-case-capitalize-first-letter-of-sentences/ ; Example .......: No ; =============================================================================================================================== Func _SentenceCase(ByRef $sString) Local $aStr = StringRegExp($sString, "(*UCP)(?s)[[:alpha:]].+?(?:[.?!:;]|\z)\s*|[^[:alpha:]]+", 3) If @error Then Return SetError(1, 0, 0) Local $sChar, $sRet = "" For $i = 0 To UBound($aStr) - 1 If StringRegExp($aStr[$i], "(*UCP)(?s)^[[:alpha:]]+.*?[.?!:;]") Then $sChar = StringLeft($aStr[$i], 1) If StringIsLower($sChar) Then $aStr[$i] = StringUpper($sChar) & StringTrimLeft($aStr[$i], 1) EndIf EndIf $sRet &= $aStr[$i] Next Return $sRet EndFunc CHANGE LOG: 28-MAR-2015 - initial version 30-MAR-2015 - added more sentence terminition characters ( ; : ) - should probably get these from a variable?
  3. i read that too, but it did say "by default" -- i don't know what that means, but i would wonder if PCRE would support these escapes simply by compiling with a different switch perhaps???
  4. done: https://www.autoitscript.com/trac/autoit/ticket/2987 thanks
  5. AHK supports this and it sure would make case changes easier... \l lowercase next char (think vi) \u uppercase next char (think vi) \L lowercase until \E (think vi) \U uppercase until \E (think vi) example: StringRegExpReplace("this. that", "\. ([a-z])", ". \u1") ; returns: this. That ref: http://perldoc.perl.org/perlre.html
  6. very sorry - i read your post wrong it works fine
  7. @Melba23 - are you sure you replaced the attachment in the first post? dragging below the list (but within the LV) does not move the bottom item to the top for me - i just quickly tried it using the first LV in example 5 other than that it works great thanks!
  8. hi Melba - works fine for me also! there's still an issue with flickering of the dragged item when you drag it off of the list, or outside of list content, but that's a rather minor visual thing
  9. little bug... drag the last item (tom 4) down, but keep it inside the LV control, then release it - you'll see what i mean you can test this example, or any of the examples included with the function package #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" $hGUI = GUICreate("Test", 400, 400) ; Create ListViews $cLV_Tom = GUICtrlCreateListView("Tom",10, 30, 300, 300) _GUICtrlListView_SetColumnWidth($cLV_Tom, 0, 140) ; Create arrays and fill ListViews Global $aTom[5] For $i = 0 To 4 $aTom[$i] = "Tom " & $i GUICtrlCreateListViewItem($aTom[$i], $cLV_Tom) Next ; Initiate ListViews and set differing external drag/drop states GUICtrlCreateLabel("Normal", 10, 10, 180, 20) $iLV_Tom = _GUIListViewEx_Init($cLV_Tom, $aTom, 0, 0, True) ; External drag & drop - items deleted on drag GUISetState() _GUIListViewEx_MsgRegister() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd also, i might suggest adding a return value after a successful call to _GUIListViewEx_WM_LBUTTONUP_Handler() if you think it might be worth while in my case, i need to re-order items in a file after the LV is re-ordered
  10. it's just an assumption if you run across text like example.com within an article or whatever, http will likely work
  11. that doesn't prefix the string with "http" if it's missing, so it is not a valid hyperlink in order to do this with only StringRegExpReplace, i am pretty sure the "Conditional patterns" for StrinRegExp needs to be utilized
  12. Sorry, the "1" could be anything and the "A" could be anything. I just made the example as simple as i could. What i'm actually trying to do is find text links in a string and wrap them in HTML to make hyperlinks. So the string could be something like: go to ex.com but don't go to http://ex2.de or https://ex3.eu The result needs to be: go to <a href="ex.com">ex.com</a> but don't go to <a href="http://ex2.de">http://ex2.de</a> or <a href="https://ex3.eu">https://ex3.eu</a> The problem i'm having with StringRegExpReplace is that, if the https? is present, then the it gets doubled. I need to add it only if it is not present using only StringRegExpReplace. If this can't be done i can do it another way, but i'd like to see if it can.
  13. Don't know if this is possible, but given the example strings: 1A A I want to find the string: (d)?([A-Z]) and if the digit is not present, then i want to add it using StringRegExpReplace. So given the example strings, the result in both cases should be: 1A This is trivial to do using a method other than StringRegExpReplace, but i want to see if this can be done this way... just because. It seems like the "Conditional patterns" section of the help doc for StringRegExp might hold the key, but i have not been able to get it to work. Here are a couple match patterns i tried: (d)?(?(1)|1)([A-Z]) (d)?(?(1)$1|1)([A-Z]) (d)?(?(1)g1|1)([A-Z]) And replace pattern is a generic $1$2$3
  14. if your concern is one of space on the users drive, and if you are open to using an installer, Inno Setup can handle that for you and you can get rid of the FileInstall function there may be other ways, but that is all that comes to mind at the moment
×
×
  • Create New...