yton Posted May 11, 2010 Share Posted May 11, 2010 (edited) Greetings,need to swap 2 or more blank spaces in the text (=string) to 1 blank space using StringRegExpReplaceplease, help with a reg. expr.thanks, Edited May 11, 2010 by yton Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2010 Moderators Share Posted May 11, 2010 yton, And what have you tried so far that has not worked? Remember it always helps if you have a go yourself first. M23 $sString = "spaces one two three four" ConsoleWrite($sString & @CRLF) $sNewString = StringRegExpReplace($sString, "(\x20+)", " ") ConsoleWrite($sNewString & @CRLF) 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...
Xenobiologist Posted May 11, 2010 Share Posted May 11, 2010 I assume StringStripWS is faster. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2010 Moderators Share Posted May 11, 2010 Xenobiologist,I assume StringStripWS is fasterNot sure about faster, but certainly easier! However, in his recent topics the OP seems to want to learn about SREs so I was trying to help out. 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...
Xenobiologist Posted May 11, 2010 Share Posted May 11, 2010 Yes yes, no problem Melba23. Your post was absolutly correct and maybe the one the OP is looking for. I for myself always try to understand what th OP wants to do and then try to offer a solution without the technique the OP mentioned. This is sometimes good, somtimes not. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Malkey Posted May 11, 2010 Share Posted May 11, 2010 Another example. Local $sStr = " 12 ab" & @TAB & " #" & @TAB & "& " ConsoleWrite(StringRegExpReplace($sStr, "\h+", " ") & @CRLF) ; or ; StringStripWS()- Does not recognize @TAB as being more than one (1) horizontal white space. ConsoleWrite(StringStripWS($sStr, 4) & @CRLF) Link to comment Share on other sites More sharing options...
yton Posted May 11, 2010 Author Share Posted May 11, 2010 $sNewString = StringRegExpReplace($sString, "(\x20+)", " ") is 100% ok i always go myself first - however, studying AutoIt for about a week only, i still cannot get all the details and i appreciate your help & advise very much thanks again 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