yton Posted May 10, 2010 Share Posted May 10, 2010 Greetings,is there a non-ClipGet alternative for StringRegExpReplace?I need to swap word1 with expression {word2|word3|word4}AutoIt Help says: "To separate back-references from actual (replaced) numbers, wrap it with half-round brackets, i.e: "${1}5"."so, i get an output with errors because of the above mentioned built-in functionalityany ideas?thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2010 Moderators Share Posted May 10, 2010 yton, We need a bit more than that to offer any sensible advice. Please give us at least one example of an original and a final string, together with what you have been using as code to run the RegEx . 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...
yton Posted May 10, 2010 Author Share Posted May 10, 2010 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 $title = GUICtrlRead($Input1, 1) $title = StringRegExpReplace($title, "word1", "{word2|word3|word4}") Run('Notepad.exe') Sleep(1000) Send($title) EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
zorphnog Posted May 10, 2010 Share Posted May 10, 2010 Again, as @Melba23 requested, we need more info. What is your input string? What do you want the returned string to be? It's hard to understand what exactly you are trying to do without a better explanation. As it is right now, it appears that you have the pattern and replacement values switched. Perhaps you meant: $title = StringRegExpReplace($title, "{word2|word3|word4}", "word1") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2010 Moderators Share Posted May 10, 2010 yton,What are "word1" and "{word2|word3|word4}"? Are they literal strings? Because if so the RegEx will only ever do anything if you have the literal string "word1" in $title.Are you looking to replace the first word of $title with other words?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...
yton Posted May 10, 2010 Author Share Posted May 10, 2010 (edited) well, i have a form with $Input1say, i put there (in $Input1) the sentence: "Word1 bla bla bla bla bla"the required output sentence is "{Word2|Word3|Word4} bla bla bla bla bla", where1) Word1, Word2, Word3 and Word4 are simple words like (e.g.) Big, Huge, Massive, Great2) first word or not - it is not important. Word1 can be anywhere in the sentenseThe thing is that i cannot get exact element "{Word2|Word3|Word4}" using StringRegExpReplace as AutoIt Help says the following about this function: "To separate back-references from actual (replaced) numbers, wrap it with half-round brackets, i.e: "${1}5"."so, i get an output with errors because of the above mentioned built-in functionalityso, i need to leave StringRegExpReplace for other function that will provide exactly {Word2|Word3|Word4} with half-round brackets Edited May 10, 2010 by yton Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2010 Moderators Share Posted May 10, 2010 yton,Why did you think you needed "back-references"? What you need is to escape the curly brackets so the RegEx recognises tham as part of the pattern: $sString = "bla bla Word1 bla bla" $sResult = StringRegExpReplace($sString, "(?i)(Word1)", "\{Word2|Word3|Word4\}") MsgBox(0, "Result", $sResult)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...
yton Posted May 10, 2010 Author Share Posted May 10, 2010 (edited) thank you all ) the solution is simple as @#$%^^& While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 $title = GUICtrlRead($Input1, 1) $title = StringRegExpReplace($title, "word1", "{word2|word3|word4}") Run('Notepad.exe') Sleep(1000) Send($title, 1) ; this is it! EndSelect WEnd EndFunc Edited May 10, 2010 by yton Link to comment Share on other sites More sharing options...
GEOSoft Posted May 10, 2010 Share Posted May 10, 2010 Again, as @Melba23 requested, we need more info. What is your input string? What do you want the returned string to be? It's hard to understand what exactly you are trying to do without a better explanation. As it is right now, it appears that you have the pattern and replacement values switched. Perhaps you meant: $title = StringRegExpReplace($title, "{word2|word3|word4}", "word1") I know, old habits die hard. Just an FYI, that RegEx example you posted will fail miserably with PCRE because of the curly braces and a lack of word boundary matching. I think what you wanted was "\b(word2|word3|word4)\b" \b is for word boundary to make sure it's only complete words and without that you could run into a problem like word2 actually being the word "and" where it would match "wand", "band", "and", "land" & etc 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...
Moderators Melba23 Posted May 10, 2010 Moderators Share Posted May 10, 2010 George, When I grow up will I be able to understand SREs too? 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...
GEOSoft Posted May 10, 2010 Share Posted May 10, 2010 (edited) That question begs 2 more questions:With all the available flavors of SRE, does anyone truly understand them all?Are you ever going to grow up?EDIT: I think I gave you a link for testing SRE's. Try using it. It was updated today too. Edited May 10, 2010 by GEOSoft 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...
Moderators Melba23 Posted May 10, 2010 Moderators Share Posted May 10, 2010 George,1. I hope not - who would want to live in that brain? 2. You must have guessed my motto: "Growing old is obligatory - growing up is entirely voluntary!" 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...
GEOSoft Posted May 10, 2010 Share Posted May 10, 2010 George,1. I hope not - who would want to live in that brain? 2. You must have guessed my motto: "Growing old is obligatory - growing up is entirely voluntary!" M23Great motto and I subscribe to that 100%. Now go back and read my edit, which was done to make your life easier. 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...
Moderators Melba23 Posted May 10, 2010 Moderators Share Posted May 10, 2010 George, How do you think I tested the one I suggested? 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...
GEOSoft Posted May 10, 2010 Share Posted May 10, 2010 George,How do you think I tested the one I suggested? M23Well I didn't test it but it must work then. Suggest the update though, there was a serious typo in the old one and I still don't know why it never threw an error. 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