WhiteBoyCat Posted June 6, 2011 Posted June 6, 2011 I am using CVSLib.au3 and taht is a GREAT! Include for Autoit. It has so many great functions. But there is one problem I am facing. With excel it adds quotation marks as escape characters for example: "Spanish, Chris" I am trying to automate filling and I need the name only. So How do I remove the quotation marks around this name? The problem is: it is not always the case that I have to remove the quotation marks. How do I make a check to See if there are quotation marks and remove them if their are?
water Posted June 6, 2011 Posted June 6, 2011 (edited) Something like this. When the first character is a quotation I assume that the tring is quoted.$sName = '"Spanish, Chris"' ConsoleWrite("Before: " & $sName & @CRLF) If Stringleft($sName,1) = '"' Then $sName = StringMid($sName,2,Stringlen($sName)-2) ConsoleWrite("After: " & $sName & @CRLF)It could be done with regular expressions using function StringRegExprReplace as well but I'm not familiar with SRE. Edited June 6, 2011 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ascend4nt Posted June 6, 2011 Posted June 6, 2011 Assuming there's no whitespace before/after, you can use this (or add in \s* where necessary): $sStr='"Spanish, Chris"' $sStr=StringRegExpReplace($sStr,'(^"|"$)','') My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
VertigoRay Posted February 25, 2013 Posted February 25, 2013 (edited) On 6/6/2011 at 2:11 PM, 'Ascend4nt said: Assuming there's no whitespace before/after, you can use this (or add in s* where necessary): $sStr='"Spanish, Chris"' $sStr=StringRegExpReplace($sStr,'(^"|"$)','') $sStr=StringRegExpReplace($sStr,'^[ ]*"|"[ ]*$','') This will get the whitespace you're talking about. Also, no point in wasting cycles on capturing if you're not doing anything with it. Cheers! Note: I realize this post is old, but I wanted to post an alternative regex solution to the one provided. Edited January 8, 2018 by VertigoRay Figure IT out!http://vertigion.com
Nessie Posted February 25, 2013 Posted February 25, 2013 $sStr=StringRegExpReplace($sStr,'^[ ]*"|"[ ]*$','') This will get the whitespace you're talking about. Also, no point in wasting cycles on capturing if you're not doing anything with it. Cheers! I think he already solved his problem Hi! refack 1 My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file
refack Posted Wednesday at 04:11 PM Posted Wednesday at 04:11 PM $f = StringRegExpReplace($f,'^[ "]*|([^\\])[ "]*$','\1') In cases where the string is a path, we should consider the case where the last `"` is escaped...
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