BennyBB Posted November 6, 2009 Share Posted November 6, 2009 Hi there, I'm even new to AutoIT and just occupied myself with a little script, that should replace some variables in a script. It works like this: You put your script into the clipboard. Then you tell the GUI what to replace e.g. $a should be replaced with $bb The problem is, that i didnt find out, how to make string replace just replacing EXACT MATCHES. E.g.: $a = 55 $ab = 10 replace $a with $b => he returns $b = 55 $bb = 10 But that's wrong I want to replace just $a and not $ab => $b = 55 $ab = 10 Pleace help me Here's the Script: expandcollapse popup#cs Code-Variable replacer by BennyBB #ce #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $Input1 = GUICtrlCreateInput("", 60, 40, 185, 21) $Input2 = GUICtrlCreateInput("", 370, 40, 185, 21) $Input6 = GUICtrlCreateInput("", 60, 90, 185, 21) $Input3 = GUICtrlCreateInput("", 370, 90, 185, 21) $Input7 = GUICtrlCreateInput("", 60, 140, 185, 21) $Input4 = GUICtrlCreateInput("", 370, 140, 185, 21) $Input8 = GUICtrlCreateInput("", 60, 190, 185, 21) $Input5 = GUICtrlCreateInput("", 370, 190, 185, 21) $input9 = GUICtrlCreateInput("", 60, 240, 185, 21) $input10 = GUICtrlCreateInput("", 370, 240, 185, 21) $input11 = GUICtrlCreateInput("", 60, 290, 185, 21) $input12 = GUICtrlCreateInput("", 370, 290, 185, 21) $Label1 = GUICtrlCreateLabel("$", 15, 40, 36, 17) $Label2 = GUICtrlCreateLabel("$", 15, 90, 36, 17) $Label3 = GUICtrlCreateLabel("$", 15, 140, 36, 17) $Label4 = GUICtrlCreateLabel("$", 15, 190, 36, 17) $Label5 = GUICtrlCreateLabel("wird zu $", 300, 40, 76, 17) $Label6 = GUICtrlCreateLabel("wird zu $", 300, 90, 60, 17) $Label7 = GUICtrlCreateLabel("wird zu $", 300, 140, 60, 17) $Label8 = GUICtrlCreateLabel("wird zu $", 300, 190, 60, 17) $Label9 = GUICtrlCreateLabel("$", 15, 240, 36, 17) $label10 = GUICtrlCreateLabel("wird zu $", 300, 240, 60, 17) $label11 = GUICtrlCreateLabel("$", 15, 290, 36, 17) $label12 = GUICtrlCreateLabel("wird zu $", 300, 290, 60, 17) $Button1 = GUICtrlCreateButton("Start", 176, 304, 273, 73, $WS_GROUP) $Button2 = GUICtrlCreateButton("Add", 24, 248, 121, 33, $WS_GROUP) GUICtrlSetState($input9,$GUI_HIDE) GUICtrlSetState($input10,$GUI_HIDE) GUICtrlSetState($input11,$GUI_HIDE) GUICtrlSetState($input12,$GUI_HIDE) GUICtrlSetState($label9,$GUI_HIDE) GUICtrlSetState($label10,$GUI_HIDE) GUICtrlSetState($label11,$GUI_HIDE) GUICtrlSetState($label12,$GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $add = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $input1 = "$" & GUICtrlRead($input1) $input2 = "$" & GUICtrlRead($input2) $input3 = "$" & GUICtrlRead($input3) $input4 = "$" & GUICtrlRead($input4) $input5 = "$" & GUICtrlRead($input5) $input6 = "$" & GUICtrlRead($input6) $input7 = "$" & GUICtrlRead($input7) $input8 = "$" & GUICtrlRead($input8) If $add = 1 Then $input9 = "$" & GUICtrlRead($input9) $input10 = "$" & GUICtrlRead($input10) $input11 = "$" & GUICtrlRead($input11) $input12 = "$" & GUICtrlRead($input12) EndIf GUIDelete($form1) replace () Case $button2 Guictrlsetstate($label9,$GUI_SHOW) GUICtrlSetState($input10,$GUI_SHOW) GUICtrlSetState($label11,$GUI_SHOW) GUICtrlSetState($label12,$GUI_SHOW) GUICtrlSetState($input9,$GUI_SHOW) GUICtrlSetState($input12,$GUI_show) GUICtrlSetState($input11,$GUI_SHOW) GUICtrlSetState($label10,$GUI_SHOW) GUICtrlSetPos($button1,176,354) GUICtrlSetState($button2,$GUI_HIDE) Dim $add = 1 EndSwitch WEnd Func replace () $code = CliPGet() MsgBox (0,"",$code) If $code = 1 Then ToolTip ("No text in clipboard") ElseIf IsString($code) = 1 Then $code = StringReplace ($code,$input1,$input2,0,1) $code = StringReplace ($code,$input3,$input4,0,1) $code = StringReplace ($code,$input5,$input6,0,1) $code = StringReplace ($code,$input7,$input8,0,1) $code = StringReplace ($code,$input9,$input10,0,1) $code = StringReplace ($code,$input11,$input12,0,1) MsgBox (0,"",$code) ClipPut($code) EndIf Exit EndFunc Link to comment Share on other sites More sharing options...
memoryoverflow Posted November 6, 2009 Share Posted November 6, 2009 (edited) $a = 55$ab = 10replace $a with $b=> he returns$b = 55$bb = 10But that's wrong I want to replace just $a and not $ab=>$b = 55$ab = 10You don't really tell what the String is, in which you want the replacement to occur. If it's the whole text, like:Local $sText = '$a = 55' & @CRLF & '$ab = 10'you could useLocal $sChanged = StringReplace($sText, '$a ', '$b ') Edited November 6, 2009 by memoryoverflow (The signature is placed on the back of this page to not disturb the flow of the thread.) Link to comment Share on other sites More sharing options...
Authenticity Posted November 6, 2009 Share Posted November 6, 2009 Few notes:- When you want to treat a global variable, doing Dim $add = 1 doesn't set the global one if in context of another scope (like within another function) but create a local one, set it's value to 1 and the global $add is still 0 so take this into consideration. - The inputs are not ordered correctly so it's something like:input1 input2 input6 input3..making StringReplace to replace wrong content.Have a look:expandcollapse popup#cs Code-Variable replacer by BennyBB #ce #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $Input1 = GUICtrlCreateInput("", 60, 40, 185, 21) $Input2 = GUICtrlCreateInput("", 370, 40, 185, 21) $Input6 = GUICtrlCreateInput("", 60, 90, 185, 21) $Input3 = GUICtrlCreateInput("", 370, 90, 185, 21) $Input7 = GUICtrlCreateInput("", 60, 140, 185, 21) $Input4 = GUICtrlCreateInput("", 370, 140, 185, 21) $Input8 = GUICtrlCreateInput("", 60, 190, 185, 21) $Input5 = GUICtrlCreateInput("", 370, 190, 185, 21) $input9 = GUICtrlCreateInput("", 60, 240, 185, 21) $input10 = GUICtrlCreateInput("", 370, 240, 185, 21) $input11 = GUICtrlCreateInput("", 60, 290, 185, 21) $input12 = GUICtrlCreateInput("", 370, 290, 185, 21) $Label1 = GUICtrlCreateLabel("$", 15, 40, 36, 17) $Label2 = GUICtrlCreateLabel("$", 15, 90, 36, 17) $Label3 = GUICtrlCreateLabel("$", 15, 140, 36, 17) $Label4 = GUICtrlCreateLabel("$", 15, 190, 36, 17) $Label5 = GUICtrlCreateLabel("wird zu $", 300, 40, 76, 17) $Label6 = GUICtrlCreateLabel("wird zu $", 300, 90, 60, 17) $Label7 = GUICtrlCreateLabel("wird zu $", 300, 140, 60, 17) $Label8 = GUICtrlCreateLabel("wird zu $", 300, 190, 60, 17) $Label9 = GUICtrlCreateLabel("$", 15, 240, 36, 17) $label10 = GUICtrlCreateLabel("wird zu $", 300, 240, 60, 17) $label11 = GUICtrlCreateLabel("$", 15, 290, 36, 17) $label12 = GUICtrlCreateLabel("wird zu $", 300, 290, 60, 17) $Button1 = GUICtrlCreateButton("Start", 176, 304, 273, 73, $WS_GROUP) $Button2 = GUICtrlCreateButton("Add", 24, 248, 121, 33, $WS_GROUP) GUICtrlSetState($input9,$GUI_HIDE) GUICtrlSetState($input10,$GUI_HIDE) GUICtrlSetState($input11,$GUI_HIDE) GUICtrlSetState($input12,$GUI_HIDE) GUICtrlSetState($label9,$GUI_HIDE) GUICtrlSetState($label10,$GUI_HIDE) GUICtrlSetState($label11,$GUI_HIDE) GUICtrlSetState($label12,$GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $add = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $input1 = "$" & GUICtrlRead($input1) $input2 = "$" & GUICtrlRead($input2) $input3 = "$" & GUICtrlRead($input3) $input4 = "$" & GUICtrlRead($input4) $input5 = "$" & GUICtrlRead($input5) $input6 = "$" & GUICtrlRead($input6) $input7 = "$" & GUICtrlRead($input7) $input8 = "$" & GUICtrlRead($input8) If $add = 1 Then $input9 = "$" & GUICtrlRead($input9) $input10 = "$" & GUICtrlRead($input10) $input11 = "$" & GUICtrlRead($input11) $input12 = "$" & GUICtrlRead($input12) EndIf GUIDelete($form1) replace() Exit Case $button2 Guictrlsetstate($label9,$GUI_SHOW) GUICtrlSetState($input10,$GUI_SHOW) GUICtrlSetState($label11,$GUI_SHOW) GUICtrlSetState($label12,$GUI_SHOW) GUICtrlSetState($input9,$GUI_SHOW) GUICtrlSetState($input12,$GUI_show) GUICtrlSetState($input11,$GUI_SHOW) GUICtrlSetState($label10,$GUI_SHOW) GUICtrlSetPos($button1,176,354) GUICtrlSetState($button2,$GUI_HIDE) $add = 1 EndSwitch WEnd Func replace () $code = CliPGet() If @error Then ToolTip ("No text in clipboard") ElseIf IsString($code) Then MsgBox (0,"",$code) If StringLen($input1) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input1 & "\E", "\" & $input2) If StringLen($input3) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input3 & "\E", "\" & $input4) If StringLen($input5) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input6 & "\E", "\" & $input6) If StringLen($input7) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input7 & "\E", "\" & $input8) If $add = 1 Then If StringLen($input9) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input9 & "\E", "\" & $input10) If StringLen($input11) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input11 & "\E", "\" & $input12) EndIf MsgBox(0, "", $code) ClipPut($code) EndIf EndFuncIt's using StringRegExpReplace to have more control on the search and replace pattern. Link to comment Share on other sites More sharing options...
BennyBB Posted November 7, 2009 Author Share Posted November 7, 2009 (edited) First of all Thanks for the fast answers and TipsI even read about this RegExp stuff but I thought that would be too complicated for me with all these pattern stuff etc.so, thanks for this part I Fixed some of the bugs (e.g. the wrong input order) but it's still not returning, what I wanted to be returnedHere is again a little example :$a = 55 $ab = 10 $aab = 'aac' $uo = 745but he returns$q = 55 $qb = 10 $qab = 'aac' $wo = 745but actually I wanted to get this:$q = 55 $ab = 10 $t = 'aac' $uo = 745Is this even possible??????Thanks in advancebtw i forgot this :this is the current code:expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $Input1 = GUICtrlCreateInput("", 60, 40, 185, 21) $Input2 = GUICtrlCreateInput("", 370, 40, 185, 21) $Input6 = GUICtrlCreateInput("", 60, 90, 185, 21) $Input3 = GUICtrlCreateInput("", 370, 90, 185, 21) $Input7 = GUICtrlCreateInput("", 60, 140, 185, 21) $Input4 = GUICtrlCreateInput("", 370, 140, 185, 21) $Input8 = GUICtrlCreateInput("", 60, 190, 185, 21) $Input5 = GUICtrlCreateInput("", 370, 190, 185, 21) $input9 = GUICtrlCreateInput("", 60, 240, 185, 21) $input10 = GUICtrlCreateInput("", 370, 240, 185, 21) $input11 = GUICtrlCreateInput("", 60, 290, 185, 21) $input12 = GUICtrlCreateInput("", 370, 290, 185, 21) $Label1 = GUICtrlCreateLabel("$", 15, 40, 36, 17) $Label2 = GUICtrlCreateLabel("$", 15, 90, 36, 17) $Label3 = GUICtrlCreateLabel("$", 15, 140, 36, 17) $Label4 = GUICtrlCreateLabel("$", 15, 190, 36, 17) $Label5 = GUICtrlCreateLabel("wird zu $", 300, 40, 76, 17) $Label6 = GUICtrlCreateLabel("wird zu $", 300, 90, 60, 17) $Label7 = GUICtrlCreateLabel("wird zu $", 300, 140, 60, 17) $Label8 = GUICtrlCreateLabel("wird zu $", 300, 190, 60, 17) $Label9 = GUICtrlCreateLabel("$", 15, 240, 36, 17) $label10 = GUICtrlCreateLabel("wird zu $", 300, 240, 60, 17) $label11 = GUICtrlCreateLabel("$", 15, 290, 36, 17) $label12 = GUICtrlCreateLabel("wird zu $", 300, 290, 60, 17) $Button1 = GUICtrlCreateButton("Start", 176, 304, 273, 73, $WS_GROUP) $Button2 = GUICtrlCreateButton("Add", 24, 248, 121, 33, $WS_GROUP) GUICtrlSetState($input9,$GUI_HIDE) GUICtrlSetState($input10,$GUI_HIDE) GUICtrlSetState($input11,$GUI_HIDE) GUICtrlSetState($input12,$GUI_HIDE) GUICtrlSetState($label9,$GUI_HIDE) GUICtrlSetState($label10,$GUI_HIDE) GUICtrlSetState($label11,$GUI_HIDE) GUICtrlSetState($label12,$GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Dim $add = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $input1 = "$" & GUICtrlRead($input1) $input2 = "$" & GUICtrlRead($input2) $input3 = "$" & GUICtrlRead($input3) $input4 = "$" & GUICtrlRead($input4) $input5 = "$" & GUICtrlRead($input5) $input6 = "$" & GUICtrlRead($input6) $input7 = "$" & GUICtrlRead($input7) $input8 = "$" & GUICtrlRead($input8) If $add = 1 Then $input9 = "$" & GUICtrlRead($input9) $input10 = "$" & GUICtrlRead($input10) $input11 = "$" & GUICtrlRead($input11) $input12 = "$" & GUICtrlRead($input12) EndIf GUIDelete($form1) replace() Exit Case $button2 Guictrlsetstate($label9,$GUI_SHOW) GUICtrlSetState($input10,$GUI_SHOW) GUICtrlSetState($label11,$GUI_SHOW) GUICtrlSetState($label12,$GUI_SHOW) GUICtrlSetState($input9,$GUI_SHOW) GUICtrlSetState($input12,$GUI_show) GUICtrlSetState($input11,$GUI_SHOW) GUICtrlSetState($label10,$GUI_SHOW) GUICtrlSetPos($button1,176,354) GUICtrlSetState($button2,$GUI_HIDE) local $add = 1 EndSwitch WEnd Func replace () $code = CliPGet() If @error Then ToolTip ("No text in clipboard") ElseIf IsString($code) Then MsgBox (0,"",$code) If StringLen($input1) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input1 & "\E", "\" & $input2) If StringLen($input6) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input6 & "\E", "\" & $input3) If StringLen($input7) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input7 & "\E", "\" & $input4) If StringLen($input8) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input8 & "\E", "\" & $input5) If StringLen($input9) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input9 & "\E", "\" & $input10) If StringLen($input11) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(^|\b)\Q" & $input11 & "\E", "\" & $input12) MsgBox(0, "", $code) ClipPut($code) EndIf EndFunc Edited November 7, 2009 by BennyBB Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 7, 2009 Moderators Share Posted November 7, 2009 BennyBB,The SRE patterns were replacing all instances, not complete ones. Try this version - it gives me what you want in your last post:expandcollapse popup#cs Code-Variable replacer by BennyBB #ce #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $sText = "$a = 55" & @CRLF & "$ab = 10" & @CRLF & "$aab = 'aac'" & @CRLF & "$uo = 745" ClipPut($sText) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $Input1 = GUICtrlCreateInput("", 60, 40, 185, 21) $Input2 = GUICtrlCreateInput("", 370, 40, 185, 21) $Input3 = GUICtrlCreateInput("", 60, 90, 185, 21) $Input4 = GUICtrlCreateInput("", 370, 90, 185, 21) $Input5 = GUICtrlCreateInput("", 60, 140, 185, 21) $Input6 = GUICtrlCreateInput("", 370, 140, 185, 21) $Input7 = GUICtrlCreateInput("", 60, 190, 185, 21) $Input8 = GUICtrlCreateInput("", 370, 190, 185, 21) $input9 = GUICtrlCreateInput("", 60, 240, 185, 21) $input10 = GUICtrlCreateInput("", 370, 240, 185, 21) $input11 = GUICtrlCreateInput("", 60, 290, 185, 21) $input12 = GUICtrlCreateInput("", 370, 290, 185, 21) $Label1 = GUICtrlCreateLabel("$", 15, 40, 36, 17) $Label2 = GUICtrlCreateLabel("$", 15, 90, 36, 17) $Label3 = GUICtrlCreateLabel("$", 15, 140, 36, 17) $Label4 = GUICtrlCreateLabel("$", 15, 190, 36, 17) $Label5 = GUICtrlCreateLabel("wird zu $", 300, 40, 76, 17) $Label6 = GUICtrlCreateLabel("wird zu $", 300, 90, 60, 17) $Label7 = GUICtrlCreateLabel("wird zu $", 300, 140, 60, 17) $Label8 = GUICtrlCreateLabel("wird zu $", 300, 190, 60, 17) $Label9 = GUICtrlCreateLabel("$", 15, 240, 36, 17) $label10 = GUICtrlCreateLabel("wird zu $", 300, 240, 60, 17) $label11 = GUICtrlCreateLabel("$", 15, 290, 36, 17) $label12 = GUICtrlCreateLabel("wird zu $", 300, 290, 60, 17) $Button1 = GUICtrlCreateButton("Start", 176, 304, 273, 73, $WS_GROUP) $Button2 = GUICtrlCreateButton("Add", 24, 248, 121, 33, $WS_GROUP) GUICtrlSetState($input9,$GUI_HIDE) GUICtrlSetState($input10,$GUI_HIDE) GUICtrlSetState($input11,$GUI_HIDE) GUICtrlSetState($input12,$GUI_HIDE) GUICtrlSetState($label9,$GUI_HIDE) GUICtrlSetState($label10,$GUI_HIDE) GUICtrlSetState($label11,$GUI_HIDE) GUICtrlSetState($label12,$GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $add = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $input1 = "$" & GUICtrlRead($input1) $input2 = "$" & GUICtrlRead($input2) $input3 = "$" & GUICtrlRead($input3) $input4 = "$" & GUICtrlRead($input4) $input5 = "$" & GUICtrlRead($input5) $input6 = "$" & GUICtrlRead($input6) $input7 = "$" & GUICtrlRead($input7) $input8 = "$" & GUICtrlRead($input8) If $add = 1 Then $input9 = "$" & GUICtrlRead($input9) $input10 = "$" & GUICtrlRead($input10) $input11 = "$" & GUICtrlRead($input11) $input12 = "$" & GUICtrlRead($input12) EndIf GUIDelete($form1) replace() Exit Case $button2 Guictrlsetstate($label9,$GUI_SHOW) GUICtrlSetState($input10,$GUI_SHOW) GUICtrlSetState($label11,$GUI_SHOW) GUICtrlSetState($label12,$GUI_SHOW) GUICtrlSetState($input9,$GUI_SHOW) GUICtrlSetState($input12,$GUI_show) GUICtrlSetState($input11,$GUI_SHOW) GUICtrlSetState($label10,$GUI_SHOW) GUICtrlSetPos($button1,176,354) GUICtrlSetState($button2,$GUI_HIDE) $add = 1 EndSwitch WEnd Func replace () $code = CliPGet() If @error Then ToolTip ("No text in clipboard") ElseIf IsString($code) Then MsgBox(0, "Before", $code) ; <<<<<<<<<<<<<<<<<<<<<<<<<< If StringLen($input1) > 1 Then $code = StringRegExpReplace($code, "(?i)(\" & $input1 & "\b)", "\" & $input2) If StringLen($input3) > 1 Then $code = StringRegExpReplace($code, "(?i)(\" & $input3 & "\b)", "\" & $input4) If StringLen($input5) > 1 Then $code = StringRegExpReplace($code, "(?i)(\" & $input5 & "\b)", "\" & $input6) If StringLen($input7) > 1 Then $code = StringRegExpReplace($code, "(?i)(\" & $input7 & "\b)", "\" & $input8) If $add = 1 Then If StringLen($input9) > 1 Then $code = StringRegExpReplace($code, "(?i)(\" & $input9 & "\b)", "\" & $input10) If StringLen($input11) > 1 Then $code = StringRegExpReplace($code, "(?i)(\" & $input11 & "\b)", "\" & $input12) EndIf MsgBox(0, "After", $code) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< ClipPut($code) EndIf EndFuncYou can see I added a "\b" which looks for a word boundary - and removed some of the pattern. You can remove the <<<<<<<<<< lines when you are happy.SRE patterns are probably the hardest thing I have ever had to try to learn in programming (although I am sure there are far harder things out there!) and I am far from confident with creating them - so do not get too discouraged! I hope it helps.M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Authenticity Posted November 7, 2009 Share Posted November 7, 2009 Yeah... pattern was wrong: If StringLen($input1) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input1 & "\E(?:\b|$)", "\" & $input2) If StringLen($input6) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input6 & "\E(?:\b|$)", "\" & $input3) If StringLen($input7) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input7 & "\E(?:\b|$)", "\" & $input4) If StringLen($input8) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input8 & "\E(?:\b|$)", "\" & $input5) If StringLen($input9) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input9 & "\E(?:\b|$)", "\" & $input10) If StringLen($input11) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input11 & "\E(?:\b|$)", "\" & $input12) Link to comment Share on other sites More sharing options...
GEOSoft Posted November 7, 2009 Share Posted November 7, 2009 Yeah... pattern was wrong: If StringLen($input1) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input1 & "\E(?:\b|$)", "\" & $input2) If StringLen($input6) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input6 & "\E(?:\b|$)", "\" & $input3) If StringLen($input7) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input7 & "\E(?:\b|$)", "\" & $input4) If StringLen($input8) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input8 & "\E(?:\b|$)", "\" & $input5) If StringLen($input9) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input9 & "\E(?:\b|$)", "\" & $input10) If StringLen($input11) > 1 Then $code = StringRegExpReplace($code, "(?m)(?i)(?:^|\b)\Q" & $input11 & "\E(?:\b|$)", "\" & $input12) Well done my good man. That can probably be put into a loop too. Using For/Next Step 2 with simple GUICtrlRead() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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