sambalec Posted October 1, 2011 Posted October 1, 2011 Hi ! How can I use StringRegExp to remove white space before a string and after the string ? Example : $var = " Testéà' - 123456 " I need this result : $var2 = "Testéà' - 123456" Many thanks. :-) Sambalec
Ramzes Posted October 1, 2011 Posted October 1, 2011 (edited) Easier is using StringStripWS. $var2 = StringStripWS($var, 3) Edited October 1, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
sambalec Posted October 1, 2011 Author Posted October 1, 2011 Another problem : $test = StringStripWS(" Enghien les bains ",3) MsgBox(0,"result",$test) It doesn't work with this example, the result is " Enghien les bains " but I need "Enghien les bains" (without first and last whitespace) Can you try for me ? Thanks Sambalec
czardas Posted October 1, 2011 Posted October 1, 2011 Works fine for me. $test = StringStripWS(" Enghien les bains ",3) MsgBox(0,"result",$test & @CRLF & "contains " & StringLen($test) & " chars") operator64 ArrayWorkshop
sambalec Posted October 1, 2011 Author Posted October 1, 2011 (edited) I think its a big bug ... maybe encoding ... Can I remove the 1st and the last caracter with a special func ? Thanks EDIT : StringTrimLeft is perfect for me Sambalec Edited October 1, 2011 by sambalec
Ramzes Posted October 1, 2011 Posted October 1, 2011 I don't know. It's working for me too. $String = StringStripWS(" Hello there! ", 3) MsgBox(0, "Test", "|" & $String & "|") If it doesn't work (I don't understand why) you must use StringTrimLeft and StringTrimRight. Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
jchd Posted October 1, 2011 Posted October 1, 2011 I think its a big bug ... maybe encoding ...I don't believe so! Can you post a very short script to replicate the issue? Bonne baignade en tous cas ! 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)
czardas Posted October 1, 2011 Posted October 1, 2011 (edited) Did you run the script I posted? When I run the code, it gives me a message box saying the string contains 17 characters. Realize that spaces are characters and also form part of the string. If you got a message box saying the string contains 19 characters, then I will believe you. Edited October 1, 2011 by czardas operator64 ArrayWorkshop
Yashied Posted October 1, 2011 Posted October 1, 2011 (edited) I think its a big bug ... maybe encoding ... Are you sure that this is a whitespaces, and not any other characters? For example: $test = StringStripWS(ChrW(160) & "Enghien les bains" & ChrW(160), 3) ConsoleWrite($test & @CR) Edited October 1, 2011 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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