Search the Community
Showing results for tags 'string functions'.
-
Hy, I normaly resolve my own problems by searching it on help file but this is a matter that I didnt faced yet. I have a csv with | as a delimiter. 0001|14442142|This is a simple description message||4412145215454 0010|85854542|A second description|The text that enforces the description|4412145215455 0212|35454159|A second description|This text is formated so it has some end of lines|4412145215456 0010|85854542|A third description||4412145215457 There are thousands of lines that are extracted everyday from a database and sent to me and I need to pass it to an excel. Could you help me with this? Till now I used Notepad++ to replace the \n\r where I found that the next line didnĀ“t start with the "xxxx|" pattern but everyday are more lines. Any ideas are apreciated. Thank you
-
I haven't posted anything in the examples section for about 6-7 weeks, so felt it was that time again. This shows how to use the string functions of AutoIt and regular exp<b></b>ressions. The header pretty much explains what the function(s) do. #include <MsgBoxConstants.au3> #include <StringConstants.au3> MsgBox($MB_SYSTEMMODAL, '', _FilePrefix(@ScriptFullPath)) ; Append _ thus creating C:\Example\Test_.exe MsgBox($MB_SYSTEMMODAL, '', _FilePrefixSRE(@ScriptFullPath & '.text')) ; Append _ thus creating C:\Example\Test_.exe ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FilePrefixSRE ; Description ...: Append a prefix before the file extension. ; Syntax ........: _FilePrefixSRE($sFilePath[, $sPrefix = Default]) ; Parameters ....: $sFilePath - Filepath or name to append a prefix before the file extension. ; $sPrefix - [optional] A string value. Default is '_'. ; Return values .: Success - Filepath with the intended prefix. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _FilePrefixSRE($sFilePath, $sPrefix = Default) If $sPrefix = Default Or StringStripWS($sPrefix, $STR_STRIPALL) == '' Then $sPrefix = '_' Return StringRegExpReplace($sFilePath, '^(.+?)(\.\w+)?$', '${1}' & $sPrefix & '${2}') EndFunc ;==>_FilePrefixSRE ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FilePrefix ; Description ...: Append a prefix before the file extension. ; Syntax ........: _FilePrefix($sFilePath[, $sPrefix = Default]) ; Parameters ....: $sFilePath - Filepath or name to append a prefix before the file extension. ; $sPrefix - [optional] A string value. Default is '_'. ; Return values .: Success - Filepath with the intended prefix. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _FilePrefix($sFilePath, $sPrefix = Default) If $sPrefix = Default Or StringStripWS($sPrefix, $STR_STRIPALL) == '' Then $sPrefix = '_' Local $iDot = StringInStr($sFilePath, '.', Default, -1) - 1 If $iDot <= 0 Then $iDot = StringLen($sFilePath) Return StringLeft($sFilePath, $iDot) & $sPrefix & StringTrimLeft($sFilePath, $iDot) EndFunc ;==>_FilePrefix
- 13 replies
-
- regular expression
- string functions
-
(and 1 more)
Tagged with: