PhoenixXL Posted October 31, 2012 Share Posted October 31, 2012 (edited) Hello EveryoneThis topic is only created to receive and supply help about regular expressionsAnybody having any problems with regular expressions please post hereI expect to Learn Regular Expression by sharing it with the Forum MembersMy first Problemi.e Im getting the quotes though it is in the non-capturing groupWhat i want is to get the text inside the quotes[excluding the quotes]#include <Array.au3> Func RegEx($nString) Local $nPattern = "(?:['"& '"])' & "[^'"& '"]*?' & '(?:["' & "'])" ConsoleWrite($nPattern & @CR) Local $nRegEx = StringRegExp($nString, $nPattern, 3) If @error Then Exit @extended _ArrayDisplay($nRegEx) EndFunc ;==>ReplaceScores RegEx('"Hello there" Dont include me coz im not in quotes')ExamplesBegginerExample : Get the Double Quoted Words#include <Array.au3> ;Get the Double Quoted Words ; Got help from Varian Func RegEx($nString) ;double single quotes inside single-quotes are treated as single Local $nPattern = '"([^"]*?)"' ConsoleWrite($nPattern & @CR) Local $nRegEx = StringRegExp($nString, $nPattern, 3) If @error Then Exit @extended _ArrayDisplay($nRegEx) EndFunc ;==>RegEx RegEx('"Hello there" Dont include me coz im not in quotes')Example : Delete every single vowel in a word; =============================================================================================================================== ;Link - http://www.autoitscript.com/forum/topic/145487-stringregexp-general-help/page__st__40#entry1040636 ; Aim....: To delete every single vowel in a word ; - Exception : if the first and last alphabets are vowel ignore them Local $sString = 'rejuvenation' Local $sPattern = '(?i)([^aeiou])' & _ ; (First Group) Match the starting of the Word with a Non-Vowel. '([aeiou])([^aeiou])' ; (Second group) Matching the Vowel and the following single Non-Vowel. Local $aRegEx = '' ;Set Extended for the Initiation SetExtended(1) While @extended $aRegEx = StringRegExpReplace($sString, $sPattern, '\1\3', 1) ;Assign the New String $sString = $aRegEx WEnd MsgBox ( 64, 'Return', $aRegEx ) ; ===============================================================================================================================Example : Replace the Line Number with any User Defined Number;Link - http://www.autoitscript.com/forum/topic/145487-stringregexp-general-help/#entry1028168 ;Replace the Line Number with any User Defined Number( 65 as an example) Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "(w+) [0-9]+", "$1 65") MsgBox(4096, "Title", $sRet) ;This Wont work ;Since $165 is used there is no 165 replacement (maximum 10 back-reference ) Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "(w+ )[0-9]+", "$165") MsgBox(4096, "Title", $sRet) ; ===============================================================================================================================IntermediateExample : Made some String Functions using RegExexpandcollapse popup; =============================================================================================================================== ;Link - http://www.autoitscript.com/forum/topic/145487-stringregexp-general-help/page__st__20#entry1039319 #include-once #include <Array.au3> #cs trying to make some string functions using Regular Expressions will add some more soon #ce ; #CURRENT# ===================================================================================================================== ; RegEx_StringLeft ; RegEx_StringLen ; RegEx_StringLower ; RegEx_StringMid ; RegEx_StringRepeat ; RegEx_StringReplace ; RegEx_StringReverse ; RegEx_StringRight ; RegEx_StringTrimLeft ; RegEx_StringTrimRight ; RegEx_StringUpper ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; CheckPattern ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringReplace ; Description ...: Similar to StringReplace ; Syntax ........: RegEx_StringReplace($sString, $sSearch, $sReplace[, $iInSensitive = 1[, $iOccurrence = 0[, $iContinue = False[, ; $iRegEx = False]]]]) ; Parameters ....: $sString - A string value. ; $sSearch - A string value. ; $sReplace - A string value. ; $iInSensitive[1] - [optional] An integer value. ; $iOccurrence[0] - [optional] An integer value. ; $iContinue[False] - [optional] Will Replace Continuously till the Occurrence[inclusive] ; $iRegEx[False] - [optional] Signifies that the Search and Replace terms are Regular Expressions ; Return values .: Returns the String with @extended set to the number of replacements ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: Havent added any Error Check ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringReplace($sString, $sSearch, $sReplace, $iInSensitive = 1, $iOccurrence = 0, $iContinue = False, $iRegEx = False) Local $iReverse = False ;Insensitiveness If $iInSensitive Then $iInSensitive = '(?i)' Else $iInSensitive = '' EndIf If $iOccurrence < 0 Then ;Check for Negative occurance $iReverse = True $iOccurrence *= -1 $sString = RegEx_StringReverse($sString) EndIf ;Check for special characters If Not $iRegEx Then CheckPattern( $sSearch ) If ($iOccurrence - 1) And Not $iContinue Then $sSearch = '(?s)' & $sSearch & '((.*?)(\1)){' & $iOccurrence - 1 & '}' $sReplace = '\1\3' & $sReplace EndIf EndIf ;main function Local $aRet = StringRegExpReplace($sString, $iInSensitive & $sSearch , $sReplace, $iOccurrence) Local $iExt = @extended If Not $iContinue Then $iExt = 1 If $iReverse Then $aRet = RegEx_StringReverse($sString) Return SetExtended($iExt, $aRet) EndFunc ;==>RegEx_StringReplace ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringMid ; Description ...: Extract a number of characters from the string ; Syntax ........: RegEx_StringMid($sString[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $sString - A string value. ; $iStart - [optional] An integer value. Default is 0. ; $iEnd - [optional] An integer value. Default is 0. ; Return values .: Failure - Sets @error to non-zero and returns the whole string ; Success - Returns the new stirng ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringMid($sString, $iStart = 0, $iEnd = 0) ;First Char = 0 ;If Start and End are 0 then Return the whole string If Not BitOR($iStart, $iEnd) Then Return $sString ;If Out of Bounds then Return If $iStart + $iEnd > RegEx_StringLen($sString) Then Return SetError(1, 0, $sString) If $iStart > RegEx_StringLen($sString) Then Return SetError(2, 0, $sString) If $iEnd < 0 Then Return SetError(3, 0, $sString) If $iStart < 0 Then Return SetError(4, 0, $sString) ;Carry Out the Main Function If $iStart Then $sString = StringRegExpReplace($sString, '(?s)(.{' & $iStart & '})', '', 1) If $iEnd Then $sString = StringRegExpReplace($sString, '(?s)(.{' & $iEnd & '})(.*)', '\1', 1) Return $sString EndFunc ;==>RegEx_StringMid ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringReverse ; Description ...: Reverses the String ; Syntax ........: RegEx_StringReverse($sString[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $sString - A string value. ; $iStart - [optional] An integer value. Default is 0. ; $iEnd - [optional] An integer value. Default is 0. ; Return values .: Returns the reversed string ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringReverse($sString, $iStart = 0, $iEnd = 0) Local $sStart = '', $sEnd = '' ;Get the Start which would not be reversed If $iStart > 0 Then $sStart = RegEx_StringMid($sString, 0, $iStart) ;Get the Start which would not be reversed If $iStart + $iEnd < RegEx_StringLen($sString) Then $sEnd = RegEx_StringMid($sString, RegEx_StringLen($sString) - ($iStart + $iEnd)) ;The Original String which has to be reversed $sString = RegEx_StringMid($sString, $iStart, $iEnd) ;main function Local $aRet = StringRegExp($sString, '(?s)(.)', 3) _ArrayReverse($aRet) Return $sStart & _ArrayToString($aRet, '') & $sEnd EndFunc ;==>RegEx_StringReverse ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringLen ; Description ...: Get the Length of the String ; Syntax ........: RegEx_StringLen($sString) ; Parameters ....: $sString - A string value. ; Return values .: Length of the String ; Author ........: Your Name ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringLen($sString) ;Replace Each Character StringRegExpReplace($sString, '(?s)(.)', '') ;Return the Number of replacements Return @extended EndFunc ;==>RegEx_StringLen ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringRepeat ; Description ...: Repeats the String ; Syntax ........: RegEx_StringRepeat($sString, $iTimes) ; Parameters ....: $sString - A string value. ; $iTimes - An integer value. ; Return values .: Returns the new string ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringRepeat($sString, $iTimes) Local $_ReplaceString ;make the replace string For $i = 1 To $iTimes $_ReplaceString &= '\1' Next ;Return Return StringRegExpReplace($sString, '(?s)(.*)', $_ReplaceString) EndFunc ;==>RegEx_StringRepeat ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringLeft ; Description ...: Extract Characters from the Left ; Syntax ........: RegEx_StringLeft($sString, $iCount) ; Parameters ....: $sString - A string value. ; $iCount - An integer value. ; Return values .: The extracted string ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringLeft($sString, $iCount) Return RegEx_StringMid($sString, 0, $iCount) EndFunc ;==>RegEx_StringLeft ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringRight ; Description ...: Extract Characters from the Right ; Syntax ........: RegEx_StringRight($sString, $iCount) ; Parameters ....: $sString - A string value. ; $iCount - An integer value. ; Return values .: The extracted string ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringRight($sString, $iCount) Return RegEx_StringReverse(RegEx_StringLeft(RegEx_StringReverse($sString), $iCount)) EndFunc ;==>RegEx_StringRight ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringTrimLeft ; Description ...: Strip a number of char from the left ; Syntax ........: RegEx_StringTrimLeft($sString, $iCount) ; Parameters ....: $sString - A string value. ; $iCount - An integer value. ; Return values .: The New String ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringTrimLeft($sString, $iCount) Return RegEx_StringRight($sString, RegEx_StringLen($sString) - $iCount) EndFunc ;==>RegEx_StringTrimLeft ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringTrimRight ; Description ...: Strip a number of char from the right ; Syntax ........: RegEx_StringTrimRight($sString, $iCount) ; Parameters ....: $sString - A string value. ; $iCount - An integer value. ; Return values .: The New String ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringTrimRight($sString, $iCount) Return RegEx_StringLeft($sString, RegEx_StringLen($sString) - $iCount) EndFunc ;==>RegEx_StringTrimRight ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringLower ; Description ...: Convert UpperCase to LowerCase ; Syntax ........: RegEx_StringLower($sString) ; Parameters ....: $sString - A string value. ; Return values .: The New String ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringLower($sString) Local $iOff = 0 For $i = 101 To 132 $sString = StringRegExpReplace($sString, '\' & $i + $iOff, ChrW($i - 103 + 97)) If RegEx_StringRight($i,1) = '7' Then $iOff += 2 Next Return $sString EndFunc ;==>RegEx_StringLower ; #FUNCTION# ==================================================================================================================== ; Name ..........: RegEx_StringUpper ; Description ...: Convert Lower Case to UpperCase ; Syntax ........: RegEx_StringUpper($sString) ; Parameters ....: $sString - A string value. ; Return values .: The New String ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func RegEx_StringUpper($sString) Local $iOff = 0 For $i = 141 To 172 $sString = StringRegExpReplace($sString, '\' & $i + $iOff, ChrW($i - 141 + 65)) If RegEx_StringRight($i,1) = '7' Then $iOff += 2 Next Return $sString EndFunc ;==>RegEx_StringLower ; #INTERNAL USE ONLY# =========================================================================================================== ; Name ..........: CheckPattern ; Description ...: Checks the Parameter of a RegExp ; Syntax ........: CheckPattern (Byref $sString) ; Parameters ....: $sString - [in/out] A string value. ; Return values .: Always returns 1 ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: The Search String can also include Special characters that would disrupt ; the Regexp therefore this function encloses each character in sets. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func CheckPattern (ByRef $sString ) ;enclose withing sets so that special character lose their meaning $sString = '(' & StringRegExpReplace ( $sString, '(?s)(.)', '[\1]' ) & ')' Return 1 EndFunc ; ===============================================================================================================================Example : _ArrayFindAllEx - Similar to _ArrayFindAll with Include, Exclude masksexpandcollapse popup#include <Array.au3> ;Link - http://www.autoitscript.com/forum/topic/147216-solved-is-there-any-arrayfindall-replacement-that-support-wildcard/ Local $aTest_Array[3] = ['Testing`_Temp.jpg', 'JOHN.jpeg', 'Boshe.jpeg'] Local $Ret_Array $Ret_Array = _ArrayFindAllEx( $aTest_Array, '*_Temp.jp?g|*h?.jp?g', False, 'Test*.jp?g|b*.jpeg', False ) _ArrayDisplay($Ret_Array, @extended & ' Match') #cs Wildcards * - Zero or more character + - One or more character ? - No or one character #ce ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayFindAllEx ; Description ...: Similar to _ArrayFindAll with Include, Exclude masks ; Syntax ........: _ArrayFindAllEx(Const Byref $aArray, $sIncludeMask[, $fIncSenstive = True[, $sExcludeMask = ''[, ; $fExcSenstive = True]]]) ; Parameters ....: $aArray - [in/out and const] The Array to search for the values. ; $sIncludeMask - A string value. ; $fIncSenstive - [optional] A boolean value. Default is True. ; $sExcludeMask - [optional] A string value. Default is ''. ; $fExcSenstive - [optional] A boolean value. Default is True. ; Return values .: Sucess - Returns the array of the Index of the found values ; - @extended is set to the number of items found ; Failure - Returns '' and sets @error to 1 ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: _ArrayFindAll ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _ArrayFindAllEx(ByRef Const $aArray, $sIncludeMask, $fIncSenstive = False, $sExcludeMask = '', $fExcSenstive = False) ;Set Sensitivity Values If $fIncSenstive Then $fIncSenstive = '' Else $fIncSenstive = '(?i)' EndIf If $fExcSenstive Then $fExcSenstive = '' Else $fExcSenstive = '(?i)' EndIf ;Make the Include Mask Pattern $sIncludeMask = StringRegExpReplace($sIncludeMask, '(?s)([^\w|])', '[\1]') $sIncludeMask = StringRegExpReplace($sIncludeMask, '(?s)(\[\?\])', '.?') $sIncludeMask = StringRegExpReplace($sIncludeMask, '(?s)(\[\+\])', '.+') $sIncludeMask = $fIncSenstive & '(?s)\A(' & StringRegExpReplace($sIncludeMask, '(?s)(\[\*\])', '.*') & ')\z' Local $aRet[1] ;Debug Out Include Mask Patterns ConsoleWrite($sIncludeMask & @CR) ;Get the to-include Strings For $i = 0 To UBound($aArray) - 1 If StringRegExp($aArray[$i], $sIncludeMask) Then _ArrayAdd($aRet, $i) Next _ArrayDelete($aRet, 0) If Not IsArray($aRet) Then Return 0 If Not $sExcludeMask Then Return SetExtended(UBound($aRet), $aRet) ;Make the Exclude Mask Pattern $sExcludeMask = StringRegExpReplace($sExcludeMask, '(?s)([^\w|])', '[\1]') $sExcludeMask = StringRegExpReplace($sExcludeMask, '(?s)(\[\?\])', '.?') $sExcludeMask = StringRegExpReplace($sExcludeMask, '(?s)(\[\+\])', '.+') $sExcludeMask = $fExcSenstive & '(?s)\A(' & StringRegExpReplace($sExcludeMask, '(?s)(\[\*\])', '.*') & ')\z' ;Debug Out Exclude Mask Patterns ConsoleWrite($sExcludeMask & @CR) Local $nDeleted = 0 ;Delete the to-exclude strings For $i = 0 To UBound($aRet) - 1 If StringRegExp($aArray[$aRet[$i - $nDeleted]], $sExcludeMask) Then $nDeleted += Number(_ArrayDelete($aRet, $i - $nDeleted) > 0) Next ;Done Return SetError(Not IsArray($aRet), UBound($aRet), $aRet) EndFunc ;==>_ArrayFindAllExAdvancedExample : Replaces Underscore with the following lineexpandcollapse popup; =============================================================================================================================== ;Link - http://www.autoitscript.com/forum/topic/145487-stringregexp-general-help/page__st__20#entry1038879 #include <Array.au3> ;Example : Replaces Underscore with the following line #region -Examples- Local $sString $sString = '$s = "This a short example."' & @CRLF & _ 'ConsoleWrite($s & @LF)' Display($sString, RegEx($sString)) $sString = '$s = "Another example." ; with a short comment _' & @CRLF & _ 'ConsoleWrite($s & @LF)' Display($sString, RegEx($sString)) $sString = '$s = "Yet another example _ ; tada."' & @CRLF & _ 'ConsoleWrite($s & @LF)' Display($sString, RegEx($sString)) $sString = 'DllCall("ntdll.dll", "int", "RtlCompressBuffer", _' & @LF & _ '"ushort", 2, _ ;------> CompressFormat' & @LF & _ '"ptr", $pInput, _ ;---> ptrSrceBuffer' & @LF & _ '"dword", $iSize, _ ;--> SrceBufferSize' & @LF & _ '"ptr", $pBuffer, _ ;--> ptrDestBuffer' & @LF & _ '"dword", $iBufLen, _;aa; vv;> DestBufferSize' & @LF & _ '"dword", 4096, _ ;----> ChunkSize' & @LF & _ '"dword*", 0, _ ;------> CompressedSize' & @LF & _ '"ptr", $pWrkSp) ;-----> WorkspaceBuffer' Display($sString, RegEx($sString)) $sString = 'MsgBox(4096, "Title _ v1", "This program is free software: you can redistribute it and/or modify" & _' & @LF $sString &= ' "it under the terms of the GNU General Public License " _" & _ ; Only comment!' & @LF $sString &= ' "as published by the Free Software Foundation, either version 3" & _' & @LF $sString &= ' "of the License, or (at your option) any later version.")' Display($sString, RegEx($sString) ) #endregion -Examples- Func RegEx($sString) Local $aRet = '' ;Get Each Line $aArray = StringRegExp($sString, '(?m)(?:[^\r\n]+[\r\n]|[^\r\n]+$)', 3) ;_ArrayDisplay( $aArray ) For $a = 0 To UBound($aArray) - 1 $aRet &= CheckUnderScore($aArray[$a]) ;~ MsgBox(0, '', $aRet) ;~ StringRegExpReplace( $sString, '(?s)(?x)([''"])(.*?1)([()><=+-/*,[:digit:]]?)*', '') Next If @error Then Return SetError(1, @error, -1) Return $aRet EndFunc ;==>RegEx Func CheckUnderScore($sString) Local $aRet, $Comment = False ;Replace the Quotes $aRet = StringRegExpReplace($sString, '(?s)([''"])(.*?\1)', '') ;Number of Semi-Colon in comments StringRegExpReplace($aRet, ';', '') $Comment = @extended ;Replace the Comments $aRet = StringRegExpReplace($aRet, '(?m)(;.*)(\r\n|$|\r|\n)', '') ;~ MsgBox(0, $Comment, $aRet) ;Remove Trailing Spaces $aRet = StringRegExpReplace($aRet, '(?m)(\s+)$', '' ) ;Done If StringRegExp($aRet, '(?m)(_$)') Then ;Check Comments If $Comment Then ;Replace the first semicolon which starts the comment ;~ $sString = StringMid($sString, 1, StringInStr($sString, ';', 2, $Comment * - 1) - 1) $sString = StringRegExpReplace($sString, '(.*)(;[^;]*){'& $Comment &'}', '\1') ;~ MsgBox(0, 0, $sString ) Else ;And replace the breaks $sString = StringRegExpReplace( $sString, '([\r\n])', '' ) ;~ MsgBox(0, 1, $sString ) EndIf ;Underscore Replace $sString = StringRegExpReplace($sString, '(.*)(_)', '\1') ;~ MsgBox(0, 2, $sString ) EndIf Return $sString EndFunc ;==>CheckUnderScore Func Display($sInput, $sOutput, $sLast = '\n\n') ;Display the Result ConsoleWrite(StringFormat('-Input: %s\n+Output: %s' & $sLast, $sInput, $sOutput)) EndFunc ;==>Display ; ===============================================================================================================================Example : Shorten your Sentenceexpandcollapse popup; =============================================================================================================================== ;Link - http://www.autoitscript.com/forum/topic/145487-stringregexp-general-help/page__st__20#entry1035465 #include-once Opt('TrayIconDebug', 1) #region -Index- ; Aim...........: To reduce the number of character in a sentence ; Description...: This Function deletes the vowels such that the sentences still sound the same ; Application...: Useful for texting(SMS) purposes through Internet ; Author........: Phoenix_XL #endregion -Index- #region -KeyPoints- ; Ignore the starting and ending vowels of any word ; Delete all the repeating consecutive alphabets[non-vowels] in a word ; -Excluding the last and first consecutive chars [if any] ; Remove all the single Vowels in b/w the word ; -In case of simultaneous vowels nothing is deleted ; Removes trailing WhiteSpaces #endregion -KeyPoints- #region -Example- Local $String = ClipGet() If @error Then Exit @error ConsoleWrite('+===================================' & @CR) ShortSentence($String) ConsoleWrite('+===================================' & @CR) ClipPut($String) #endregion -Example- ; #FUNCTION# ==================================================================================================================== ; Name ..........: ShortSentence ; Description ...: Trims the Vowels and Alphabets such that the phrase/sentence still sounds the same ; Syntax ........: ShortSentence(Byref $sString[, $fDebug = True]) ; Parameters ....: $sString - [in/out] A string value. The String is modified ; $fDebug - [optional] A boolean value. Default is True. ; Return values .: Returns the Original String and @extended is to the number of replacements done ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func ShortSentence(ByRef $sString, $fDebug = True) Local $aRegEx, $sBackUp = $sString, $iExt = 0 Local $sPattern = '(?i)([b-df-hj-np-tv-z])' & _ ; (First Group) Match the starting of the word with a consonant. '([aeiou])([b-df-hj-np-tv-z]+)' ; (Second group & Third group) Matching the vowel and the following consonant(s). $iExt += GeneralReplacements($sString) ;~ MsgBox ( 0, $iExt, $sString ) ;Trim Repeating Non-Vowel Alphabets $sString = StringRegExpReplace($sString, '(?i)(\B[b-df-hj-np-tv-z])(\1+\B)', '\1') $iExt += @extended ;~ MsgBox ( 0, @extended, $sString ) ;Set Extended for the Initiation SetExtended(1) While @extended ;~ MsgBox(0, $iExt, $sString) $aRegEx = StringRegExpReplace($sString, $sPattern, '\1\3', 1) $iExt += @extended - 1 ;Assign the New String $sString = $aRegEx WEnd ;Remove the trailing space/ $sString = StringStripWS($sString, 2) ;Debug out If $fDebug Then ConsoleWrite($sString & @CR) ;Completed Return SetExtended($iExt, $sBackUp) EndFunc ;==>ShortSentence ; #FUNCTION# ==================================================================================================================== ; Name ..........: GeneralReplacements ; Description ...: Change some general words ; Syntax ........: GeneralReplacements(Byref $sString) ; Parameters ....: $sString - [in/out] A string value. The String is modified ; Return values .: Returns the number of replacements performed. ; Author ........: Phoenix XL ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func GeneralReplacements(ByRef $sString) Local $aArray[9][2] = [["the", "d"],['eat|ate', '8'],['\band\b', 'n'],['good', 'gud'], _ ['should', 'sud'],['one', '1'],['to|two', '2'],['we', 'v'],['because', 'bcoz']] Local $iRet = 0 For $i = 0 To UBound($aArray) - 1 If $aArray[$i][0] = '' Then ContinueLoop $sString = StringRegExpReplace($sString, '(?i)(' & $aArray[$i][0] & ')', $aArray[$i][1]) $iRet += @extended Next Return $iRet EndFunc ;==>GeneralReplacements ; =============================================================================================================================== Edited March 22, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
guinness Posted October 31, 2012 Share Posted October 31, 2012 Firstly, threads such as this one is going to cause confusion and unnecessary necroing. Secondly, provide a before and after of what you expect. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Varian Posted October 31, 2012 Share Posted October 31, 2012 This change will work: Local $nPattern = "['"& '"]' & "([^'"& '"]*?)' & '["' & "']" I generally use the capturing groups on info that I want returned when using the Global matches (3) Link to comment Share on other sites More sharing options...
jchd Posted October 31, 2012 Share Posted October 31, 2012 You're over-complicating the pattern. "([^"]*)" will do in that precise case. JScript 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JScript Posted October 31, 2012 Share Posted October 31, 2012 Firstly, threads such as this one is going to cause confusion and unnecessary necroing.It is the typical sentence for those who already understand enough of the subject!But I do not think it will be that way, because I think it will help a lot to many people, including me.JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 31, 2012 Author Share Posted October 31, 2012 @guinnessSecondly, provide a before and after of what you expect.Thanks@JScriptI think it will help a lot to many people, including me.Indeed me too @jchdSorry its my mistake, i used it in differentiating quoted words and not quoted words@VarianThanks it worked My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 31, 2012 Author Share Posted October 31, 2012 (edited) Another questionWhy are the Null characters even getting matched#include <Array.au3> Local $iString = "Just Testing dj" RegEx($iString) Func RegEx($nString) Local $nPattern = "\w*" ConsoleWrite($nPattern & @CR) Local $nRegex = StringRegExp($nString, $nPattern, 3) If @error Then Exit @extended _ArrayDisplay($nRegex) EndFunc ;==>RegEx Edited January 6, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
guinness Posted October 31, 2012 Share Posted October 31, 2012 jchd's example should use single quotes around the expression as not to cause an error.I also have a limited understanding of regular expressions myself, but we will see where this thread goes. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jchd Posted October 31, 2012 Share Posted October 31, 2012 I just typed the required pattern without any decoration. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JScript Posted October 31, 2012 Share Posted October 31, 2012 (edited) I need to capture only the initial number after the word "Line"I need to change only the initial number after the word "Line" by any other number!I did the following:Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "d+[0-9]", 65) MsgBox(4096, "Title", $sRet)I did it with the help of this program: http://www.ultrapico.com/Expresso.htmIt's working, but there is another more efficient way of doing?JS Edited October 31, 2012 by JScript iahngy 1 http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 31, 2012 Author Share Posted October 31, 2012 this would work #include <Array.au3> Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, '([[:upper:]][[:lower:]]{3} )(d+)(?s).*', '$2') If @error Then Exit @extended MsgBox(4096, "Title", $sRet) My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 31, 2012 Author Share Posted October 31, 2012 (edited) orelse this oneLocal $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "w+ (d+[0-9])(?s).*", '$1') MsgBox(4096, "Title", $sRet) Edited October 31, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
JScript Posted October 31, 2012 Share Posted October 31, 2012 Very nice, but I'm sorry if I expressed myself badly... I need to change only the initial number after the word "Line" by any other number! JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
iamtheky Posted October 31, 2012 Share Posted October 31, 2012 (edited) Your example in post #10 would give incorrect results if the Line # were only a single digit, and/or if there is a sequence of 2 or more digits elsewhere in the string. Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "ALine [0-9]+", "Line " & 65) MsgBox(4096, "Title", $sRet) Edited October 31, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
JScript Posted October 31, 2012 Share Posted October 31, 2012 @boththose That was the first way I did, but suppose the words "Line" was another, your example would not work! JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
iamtheky Posted October 31, 2012 Share Posted October 31, 2012 (edited) but suppose the words "Line" was another, your example would not work!Then this would not be accurateI need to change only the initial number after the word "Line" by any other number!and you would be building a regexp that changes any numbers after any words? is the location of the numbers at least the same everytime? Edited October 31, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 31, 2012 Author Share Posted October 31, 2012 (edited) This one shows usage of Back-Reference;Replace the Line Number with any User Defined Number( 65 as an example) Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "(w+) [0-9]+", "$1 65") MsgBox(4096, "Title", $sRet) ;This Wont work ;Since $165 is used there is no 165 replacement (maximum 10 back-reference ) Local $sString = 'Line 10764 (File "D:DropboxAutoIt v3 - ProjectsAutoItErrorTrapExample4.exe"):' & @CRLF & _ 'Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.' Local $sRet = StringRegExpReplace($sString, "(w+ )[0-9]+", "$165") MsgBox(4096, "Title", $sRet) Edited January 6, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
JScript Posted October 31, 2012 Share Posted October 31, 2012 is the location of the numbers at least the same everytime?Yes!@PhoenixXLVery nice, both examples!JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
PhoenixXL Posted November 1, 2012 Author Share Posted November 1, 2012 (edited) Example ( not accurate - check for accurate results)-->Replaces the Underscores with the Next Line -Thanks to Varian for the original PatternLocal $iString $iString = 'DllCall("ntdll.dll", "int", "RtlCompressBuffer", _' & @LF & _ '"ushort", 2, _ ;------> CompressFormat' & @LF & _ '"ptr", $pInput, _ ;---> ptrSrceBuffer' & @LF & _ '"dword", $iSize, _ ;--> SrceBufferSize' & @LF & _ '"ptr", $pBuffer, _ ;--> ptrDestBuffer' & @LF & _ '"dword", $iBufLen, _ ;> DestBufferSize' & @LF & _ '"dword", 4096, _ ;----> ChunkSize' & @LF & _ '"dword*", 0, _ ;------> CompressedSize' & @LF & _ '"ptr", $pWrkSp) ;-----> WorkspaceBuffer' ConsoleWrite('Returned: ' & RegEx($iString) & @CR) ;Replaces the Underscores with the NextLine Func RegEx($sString) Local $sPattern = "(?m)(^.*)( _)(?:\s*$|\s*;.*\s*$)" ;Remove the Comments Local $sRegex = StringRegExpReplace($sString, $sPattern, '\1') ;Now Lets Join them Return StringRegExpReplace($sRegex, '(?m)([\r\n])', '') EndFunc ;==>RegEx Edited January 6, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
jchd Posted November 1, 2012 Share Posted November 1, 2012 Please don't double post in distinct threads and don't mix threads up. This is not how this forum works; keep it one subject = one thread. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now