Jump to content

Search the Community

Showing results for tags 'regexp'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 26 results

  1. Is there a way to output the regex matches into a file? I have a script to compare two files and check for regex matches. I want to output the matching regex of 'testexample.txt' to another file. #include <MsgBoxConstants.au3> #include <Array.au3> $Read = FileReadToArray("C:\Users\admin\Documents\testexample.txt") $Dictionary = FileReadToArray("C:\Users\admin\Documents\example.txt") For $p = 0 To UBound($Dictionary) - 1 Step 1 $pattern = $Dictionary[$p] For $i = 0 To UBound($Read) - 1 Step 1 $regex = $Read[$i] If StringRegExp($regex, $pattern, 0) Then MsgBox(0, "ResultsPass", "The string is in the file, highlighted strings: " ) Else MsgBox(0, "ResultsFail", "The string isn't in the file.") EndIf Next Next
  2. Im creating a code that will work in this sequence: 1. Copy the text (question) in one atea of the screen 2. Catch the 2 strings (number) 3. Multiply the 2 strings ( $1*$2) 4. Click the next area to put the answer 5. Paste the answer This is my code MouseClick($MOUSE_CLICK_LEFT, 479, 802, 3, 1) ;Clicking all of the text Send("^c") $x = StringRegExpReplace(ClipGet(), 'What is (\d*) x (\d*) \?$', "$1*$2") MouseClick($MOUSE_CLICK_LEFT, 480, 844, 1, 1) ClipPut($x) Send("^v") However the output is this $1*$2 How can I make it solve itself? Because I tried this code: MouseClick($MOUSE_CLICK_LEFT, 479, 802, 3, 1) ;Clicking all of the text Send("^c") MouseClick($MOUSE_CLICK_LEFT, 480, 844, 1, 1) $x = Execute(StringRegExpReplace(ClipGet(), 'What is (\d*) x (\d*) \?$', "$1*$2")) ClipPut($x) Send("^v") Output is just blank text
  3. Version 3.3

    217 downloads

    In April 5, 2013 I ask @Lazycat he answer: Then I change this tool a little. Now I back to this and make bigger changed. Here is new version. Update History: = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 2018/11/07 v3.0 * Changed: AU3Check compilant - mLipok * Changed: almost all Variables renamed - mLipok * Added: "Delete RegExp Results" - mLipok * Added: support for dual monitor - mLipok * Added: "full screen mode" - mLipok = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 2018/11/08 v3.1 * Added: colors for each Edit control - used GUICtrlSetBkColor() - mLipok * Added: FullScreen option (Checkbox + INI + Remarks in Tip) - mLipok * Added: _IsChecked() - mLipok * Changed: WinMove() - change size of window using: WindowWidth and WindowHeight - mLipok = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 2018/11/13 v3.2 * Added: If $bFullScreen Then GUICtrlSetFont() - mLipok * Added: WM_COMMAND , $EN_CHANGE - prevent CPU overheat - mLipok = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 2018/11/29 v3.3 * Changed: $_g_idCheckbox_Clear - also clear $_g_idEdit_Result - mLipok * Changed: ClearResult If GUICtrlRead($_g_idEdit_MatchText) = '' Or GUICtrlRead($_g_idEdit_MatchText) = '' - mLipok * Fixed: prevention CPU overheat - If $iGuiMsg <> 0 Then $_g_bWasAChange = True - any GUI change will fire RegExp result refresh - mLipok * Fixed: Top possition of $_g_idLabel_Dummy control - mLipok * Added: support for TabSwitch - CTRL+TAB and CTRL+SHIFT+TAB - mLipok = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  4. argh, pulling my hair out. considering this post: say for a string = "03a", how can I strip out the leading 0 and the a. I have tried: $new = StringRegExpReplace($string, '[^1-9][^0-9]', '') and various combinations: ^0+[^0-9] [^[:digit:]] "[^0].*" "^0*(d+)" I'm going loopy!
  5. Hi everyone! After updating autoit, I tried to run an old program using complex regexp's. It did not work. Eventually I broke the problem down to this example: #include <Array.au3> $buf = "First title" & @CRLF & "Tom" & Chr(0x92) & "s sleepwalking" & @CRLF & "Last | line" & @CRLF $items = StringRegExp($buf, '([\x20-\xff]+)\x0d\x0a', 3) _ArrayDisplay($items,'') And this is the result I get when running it: Row 0
  6. Hello . How to do that $regexp = starts from "abcdef" and after this could be anything in name WinActivate($regexp)
  7. Well the plan is to use the power of regular expressions engine of AutoIT for patching binary data. Something like this: StringRegExp( $BinaryData, "(?s)\x55\x8B.." <cut> ... Okay straight to question/problem ... certain bytes that are in the range from 0x80 to 0xA0 won't match. Hmm seem to be a char encoding problem. In detail these are 27 chars: 0x80, 0x82~8C, 0x8E, 0x91~9C, 0x9E,0x9F Here's a small code snippet to explore / explain this problem: #include "StringConstants.au3" $TestData = BinaryToString("0x7E7F808182") ;Okay $match = StringRegExp( $TestData ,'\x7E' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Okay $match = StringRegExp( $TestData ,'\x7F' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Error no match $match = StringRegExp( $TestData ,'\x80' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Okay $match = StringRegExp( $TestData ,'\x81' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Error no match $match = StringRegExp( $TestData ,'\x82' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;~ output: ;~ @extended = 2 $match = ;~ @extended = 3 $match = ;~ @extended = 0 $match = 1 ;~ @extended = 5 $match = ;~ @extended = 0 $match = 1 Hmm what to do? Go back and use the 'numberstring monster' implementation or just omit that range of 'unsafe bytes'. What is the root of this problem? Any idea how to fix this? Update: Okay I know a byte is not a character. But StringRegExp operates on String and so character level. Okay as long as you stay at Ansi encoding and only use /x00 - /X7F in the search pattern using StringRegExp works well to search for binary data. What bytes can be matched that are in the range from /X7F - /xFF is also depending on the code page. So this avoid to search for bytes in the range from 0x80-0xa0 only applies to Germany. I just change this country setting: to Thai and now near all bytes from /X7F - /xFF fails to match.
  8. Text in a file, read into var with fileread: <> <> <> <> < J please look > <> <> <> Hi, I want a RegExp to select around 'please', back to the previous < and forward to the next >. I can select the line of text. Then I add in (?s) and it selects the whole text. I think I want to make it not greedy, (?U) , that seems to make it ungreedy after, but it still selects all the previous lines. $sPattern = "(?s)<.*please.*>" ; 1 $sPattern = "(?s)<(?U).*please.*>" ; 2 $sPattern = "(?s)<(?U).*please(?U).*>" ; 3 $sAry = StringRegExp($sHTML, $sPattern, 3)
  9. I want to rename every new instance of notepad to notepad(random number) If I use WinSetTitle ( "notepad", "", "notepad("&$randomnumber&")" ) this will work pretty good, because if more windows match the search entry it will take the newest. But what if this code runs, but there is no new instance of notepad. It will rename one that was already assigned a number. So I would like to check whether it is already renamed. For example by excluding titles that contain a ")". How do I do that. Read this, but that is pretty confusing: http://stackoverflow.com/questions/406230/regular-expression-to-match-line-that-doesnt-contain-a-word?rq=1
  10. #include <Array.au3> If @Compiled Then Exit Global Enum $FUNC_OUTER, $FUNC_NAME, $FUNC_PARAM, $FUNC_INNER _Example() Func _Example() Local $sIncludeDir = StringTrimRight(@AutoItExe, StringLen('AutoIt3.exe')) & 'Include\' Local $aOuterArray = _GetFunctionsToArray($sIncludeDir & 'Color.au3') If Not @error Then For $iOuter_idx = 0 To UBound($aOuterArray) - 1 _ArrayDisplay($aOuterArray[$iOuter_idx], ($aOuterArray[$iOuter_idx])[$FUNC_NAME]) Next EndIf EndFunc ;==>_Example Func _GetFunctionsToArray($sUDF_FileFullPath) Local $sUDFContent = FileRead($sUDF_FileFullPath) Local $aResult = StringRegExp($sUDFContent, '(?is)\RFunc (.*?)\((.*?)\)\v\R(.*?)\REndFunc', $STR_REGEXPARRAYGLOBALFULLMATCH) Return SetError(@error, @extended, $aResult) EndFunc ;==>_GetFunctionsToArray
  11. #include <Array.au3> ; Script Start - Add your code below here Local $test = "<li>One<li>Inner<li>Innermost</li></li></li>" & _ "<li>Two</li> " $loob = StringRegExp($test, '\Q<li>\E(.*?)\Q</li>\E', 3) _ArrayDisplay($loob, "How to return the One... and Two?") Hello, can somebody help me: (1) How can I have the regexp matched the two outermost bullets? Such that: (2) How can I match the "Innermost" bullet? Thanks so much.
  12. Hello, Have been thinking about this for a while, so decided to seek for help. I have the following string: "...<tag>1</tag>...<tag>2</tag>...<tag>3</tag>...", which I need to test if all text within <tag> matches certain criteria, e.g. it's a number "\d+". The trick is 1) I need the entire match to fail if only one instance of the text between <tag> doesn't match "\d+"; 2) I need the string to match if there's no <tag>. E.g.: - "...<tag>1</tag>...<tag>2</tag>...<tag>3</tag>..." matches. - "...<tag>a</tag>...<tag>2</tag>...<tag>3</tag>..." fails. - "..." matches. Thanks!
  13. Hello, I am trying to create a regExp for following HTML text: <a href="link=1">1</a> <b>2</b> <a href="link=3">3</a> | <a href="link=2">Previous</a> | <a href="link=3">Next</a>My intention is to extract href from last <a> tag. Here is my attempt: Local $reg = '(?i)\|\s?<a href="(.*?)">Next</a>' Local $text = '<a href="link=1">1</a> <b>2</b> <a href="link=3">3</a> | <a href="link=2">Previous</a> | <a href="link=3">Next</a>' $aData = StringRegExp($text,$reg,3) ConsoleWrite($aData[0]&@LF)Now problem is i am unable to extract exact href from the last <a> tag. Here is the output: link=2">Previous</a> | <a href="link=3I know I can use other techniques, but i want to know, why my pattern is not working or what is the right pattern for such situation? Thanks in Advance.
  14. Hello, I want to capitalize 1st word of every sentence with StringRegExp, I am able to collect words by using this pattern: Local $reg = '(?:^|(?:[.!?]\s))(\w+)'now my problem is how can I exactly replace these words, e.g. In the following string: I only want to replace 1st "the" of the sentence with "The" but I have only words in array from RegExp, without its position in string. Thanks.
  15. Hi I am struggeling around with an RegExp I need to check a string, it should only contain digits and a - This is what i have so far StringRegExp($sColData,"[\s\D]",0)which returns true for every non-digit (\D) character including @CR (which should not exist as well) and whitespaces (\s], but it returns true even if the string contains a - which should return 0 How can i fix that, i want like "match any non-digits and whitespace characters except for a -" ? Best, Thomy
  16. Hello, Not sure if I asked the right question but how do I modify the pattern so that it only matches the second test string? $sTest1 = 'bErtrTRtrtXa' $sTest2 = 'ErtrTRtrtX' $sPattern = 'E[A-Za-z]{0,}X' Local $iResult1 = StringRegExp($sTest1, $sPattern) Local $iResult2 = StringRegExp($sTest2, $sPattern) ConsoleWrite('Test 1: ' & $iResult1 & @CRLF & 'Test 2: ' & $iResult2) Thanks!
  17. Hi all, How to get nth line text from a given text with Regexp. For example, i have a text from a window which contains 15 lines. And i need to get the text from 5th line (it may vary). How to do it. I have tried some patters like "(^ &)5" and "[^ $]{5}". But didn't work.
  18. Hi all, How to find first and last word in a sentence with Regular expression ?. Sentence is the code from SciTE. For example if sentence is; "For $i = 0 to 15" I need to extract "For from the sentence And the same way i need last word from a sentence "If Apple = 15 Then" I need "Then" from the sentence.
  19. I have constants A and B and C, in fact they are not one char but whole word and they can be included at the end of test text in parenthesis there can be only one of them but also two of them or all three separated by coma in any order (A) or (A,B ) or (C,A) or (A,B,C) or (A,C,B ) ... I need to get text in these parenthesis ; in comment at end of each line is what I want to get Test1('some text') ; '' Test1('some text (something)') ; '' Test1('some (something) text') ; '' --> ignore other () not at the end Test1('some (something) (A) text') ; '' --> I want only at end of string Test1('some (something) text (A)') ; 'A' Test1('some text (A)') ; A Test1('some text (B)') ; B Test1('some text (A,B,C)') ; 'A,B,C' Test1('some text (A,C,B)') ; 'A,C,B' Test1('some text (A,C,X)') ; 'A,C' --> not X Test1('some text (ABC)') ; '' --> missing , Func Test1($text) $regexp = '.*? \(([A|B|C])\)' $ret = StringRegExpReplace($text, $regexp, '$1') ConsoleWrite('regexp: ' & $regexp & ' text: ' & $text & ' --> ' & $ret & @CRLF) $regexp = '\z\(([A|B|C])\)' $ret = StringRegExpReplace($text, $regexp, '$1') ConsoleWrite('regexp: ' & $regexp & ' text: ' & $text & ' --> ' & $ret & @CRLF) $regexp = '\z\(([A|B|C]{1,3})\)' $ret = StringRegExpReplace($text, $regexp, '$1') ConsoleWrite('regexp: ' & $regexp & ' text: ' & $text & ' --> ' & $ret & @CRLF) $regexp = '\z\(([A|B|C|,]{1,3})\)' $ret = StringRegExpReplace($text, $regexp, '$1') ConsoleWrite('regexp: ' & $regexp & ' text: ' & $text & ' --> ' & $ret & @CRLF) $regexp = '.*?\(([A|B|C]{1,3})\)' $ret = StringRegExp($text, $regexp, 3) If Not @error Then $ret = $ret[0] Else $ret = '' EndIf ConsoleWrite('not replace: regexp: ' & $regexp & ' text: ' & $text & ' --> ' & $ret & @CRLF) ConsoleWrite(@CRLF) EndFunc I don't know how to use z (at end of string) and how to incorporate coma separator into my RegExp expression these my RexExp expressions are not working even for simple one value In function Test1() should be only one correct RexExp but I have there more because I want to show some of my attempts. EDIT: fixed mistake in last RegExp I hope that for RegExp gurus this will be very easy :-)
  20. I'm doing parsing of HTML file with <table>. I need to go through rows and columns of table, ideally to get two dimensional array. I use this way with simple two levels of calling StrinRegExp() for rows and columns: ;~ $html = FileRead('table.html') $html = '<tr><td>r1c1</td> <td>r1c2</td></tr> <tr><td>r2c1</td> <td>r2c2</td></tr> <tr><td>r3c1</td> <td>r3c2</td></tr>' $rows = StringRegExp($html, '(?s)(?i)<tr>(.*?)</tr>', 3) For $i = 0 to UBound($rows) - 1 $row = $rows[$i] ConsoleWrite("Row " & $i & ': ' & $row & @CRLF) $cols = StringRegExp($row, '(?s)(?i)<td>(.*?)</td>', 3) For $j = 0 to UBound($cols) - 1 $col = $cols[$j] ConsoleWrite(" Col " & $j & ': ' & $col & @CRLF) Next Next Output: In my example there is called StringRegExp() for each row of table which is ineffective for many rows. It works fine, but my question is if there is better and more effective approach, maybe some clever the only one RegExp pattern? Or maybe using StringRegExp with option=4? I 'm not experienced with this option (array in array) and example in helpfile is not very clear to me so I don't know if this option=4 can be used also for HTML table parsing.
  21. Hi all, So, I have strings where I'm trying to delimit each value, that's currently separated with spaces, with a pipe. Here are a few of the strings: "webstratauthentication\enableuserpasswordencryption.sql"02/23/2011 01:17:22 PM 1401 "12312312312312312""A" "b04ecbc4-e0e2-c14b-d780-656d348b0513" "\\nas123456n\ct40_packaging\builds\product\productname\hss\authentication\enableuserpasswordencryption.sql" "webstratauthentication\enableuserpasswordencryption.sql"02/23/2011 01:17:22 PM 1401 "" "A" "b04ecbc4-e0e2-c14b-d780-656d348b0513" "\\nas123456n\ct40_packaging\builds\product\productname\hss\authentication\enableuserpasswordencryption.sql" "ikernel.dll" 04/26/2002 07:48:38 PM 0 "" "A" "d98c1dd4-008f-04b2-e980-0998ecf8427e" "c:\program files\installshield 10.5\support\build\ikernel.dll" I'd like to return the strings looking like this: "webstratauthentication\enableuserpasswordencryption.sql"|02/23/2011|01:17:22 PM|1401|"12312312312312312"|"A"|"b04ecbc4-e0e2-c14b-d780-656d348b0513"|"\\nas123456n\ct40_packaging\builds\product\productname\hss\authentication\enableuserpasswordencryption.sql" "webstratauthentication\enableuserpasswordencryption.sql"|02/23/2011|01:17:22 PM|1401|""|"A"|"b04ecbc4-e0e2-c14b-d780-656d348b0513"|"\\nas123456n\ct40_packaging\builds\product\productname\hss\authentication\enableuserpasswordencryption.sql" "ikernel.dll"|04/26/2002|07:48:38 PM|0|""|"A"|"d98c1dd4-008f-04b2-e980-0998ecf8427e"|"c:\program files\installshield 10.5\support\build\ikernel.dll" I've tried replacing the double spaces with pipes, but that messes up the first string and leaves "12312312312312312""A" without adding the pipe between the two values. $sLine = StringRegExpReplace($sLine, "[ ]{2,}", "|") So, I concocted a way to do it with a string-based approach. ; Strip the leading and trailing ws $sTempLine = StringStripWS($sTempLine, 1 + 2) ; Replace all double spaces with pipes $sTempLine = StringRegExpReplace($sTempLine, "[ ]{2,}", "|") If StringInStr($sTempLine, '""A"') > 0 Then $sTempLine = StringReplace($sTempLine, '""A"', '"|"A"') EndIf ; And check if the file name needs a pipe after its second double quote $iPos = StringInStr($sTempLine, '"', 0, 2) If StringMid($sTempLine, $iPos, 2) <> '"|' Then $sTempLine1 = StringMid($sTempLine, 1, $iPos) $sTempLine1 &= "|" & StringMid($sTempLine, ($iPos + 1), (StringLen($sTempLine) - $iPos)) $sTempLine1 = StringReplace($sTempLine1, '" "', '"|"') $sTempLine = $sTempLine1 EndIf ConsoleWrite("-> " & $sTempLine & @CRLF) Is there a better regex that I can use to separate these values in the strings with pipes? I thought that it might be easiest to just put a pipe after every second quote... Thank you for the help.
  22. I want to generate a regex from an user input and need a regex prepare function. I couldn't find any in the documentation, am I missing something? It should escape out all regex characters, so like "te.st" would become "te.st".
  23. I want to do a RegExp for finding string (( single line ) with Local directive used inside While Wend loop. Here is what I get: TEST SCRIPT: Func _test1() Local $sTest1 = '' While 1 ;~ .... ;~ .... While 1 ;~ .... Local $sTest2 = '' ;~ .... ;~ .... WEnd ;~ .... WEnd EndFunc ;==>_test1 Func _test2() Local $sTest3 = '' While 1 ;~ .... ;~ .... While 1 ;~ .... Local $sTest4 = '' ;~ .... ;~ .... WEnd ;~ .... WEnd EndFunc ;==>_test2 REGEXP: (?is)(While.*?)(Local\V*)(?:.*?)(?=Wend) I have two problems with that REGEXP QUESTION 1: Why using that: (?is)(While.*?)(?:Local\V*)(?:.*?)(?=Wend) I have 2 groups with a duplicate text "While" Because I use that group definition (While.*?) I am puzzled why the output of the definition of the group gives me twice the text "While" ? QUESTION 2: When I had that test script: Func _test1() Local $sTest1 = '' While 1 ;~ .... ;~ .... While 1 ;~ .... ;~ .... ;~ .... WEnd ;~ .... WEnd EndFunc ;==>_test1 Func _test2() Local $sTest3 = '' While 1 ;~ .... ;~ .... While 1 ;~ .... Local $sTest4 = '' ;~ .... ;~ .... WEnd ;~ .... WEnd EndFunc ;==>_test2 I mean without: Local $sTest2 = '' and now when I use that REGEXP: (?is)(While.*?)(Local\V*)(?:.*?)(?=Wend) I have that result: GROUP 0: While 1 ;~ .... ;~ .... While 1 ;~ .... ;~ .... ;~ .... WEnd ;~ .... WEnd EndFunc ;==>_test1 Func _test2() GROUP 1: Local $sTest3 = '' ?? How to do a REGEXP witch return that GROUP: GROUP 0: While 1 ;~ .... GROUP 1: Local $sTest4 = '' EDIT: I mean without Func / EndFunc statement inside GROUP 0
  24. #include-once ; #UDF# ======================================================================================================================= ; Title .........: PathSplitEx ; AutoIt Version : 3.3.8.1 ; Language ......: English ; Description ...: Splits a path into the drive, directory, file name and file extension parts ; Author(s) .....: DXRW4E ; Notes .........: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _PathSplitEx ; _PathSplitParentDir ; _FileExistsEx ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _PathSplitEx ; Description ...: Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing. ; Syntax.........: _PathSplitEx($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension) ; Parameters ....: $sFilePath - The path to be split (Can contain a UNC server or drive letter) ; $sDrive - String to hold the drive ; $sDir - String to hold the directory ; $sFileName - String to hold the file name ; $sExtension - String to hold the file extension ; Return values .: Success - Returns an array with 5 elements where 0 = original path 1 = drive, 2 = directory, 3 = filename, 4 = extension ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function does not take a command line string. It works on paths, not paths with arguments. ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _PathSplitEx($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension) $sFilePath = StringRegExp($sFilePath, "^((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\])?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1) $sDrive = $sFilePath[1] $sDir = StringRegExpReplace($sFilePath[2], "[\/\\]+\h*", "\" & StringLeft($sFilePath[2], 1)) $sFileName = $sFilePath[3] $sExtension = $sFilePath[4] Return $sFilePath EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _PathSplitParentDir ; Description ...: Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing. ; Syntax.........: _PathSplit($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sParentDir, ByRef $sFileName, ByRef $sExtension) ; Parameters ....: $sFilePath - The path to be split (Can contain a UNC server or drive letter) ; $sDrive - String to hold the drive ; $sDir - String to hold the directory ; $sParentDir - String to hold the parent directory ; $sFileName - String to hold the file name ; $sExtension - String to hold the file extension ; Return values .: Success - Returns an array with 6 elements where 0 = original path 1 = drive, 2 = directory, 3 = parentdir, 4 = filename, 5 = extension ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function does not take a command line string. It works on paths, not paths with arguments. ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _PathSplitParentDir($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sParentDir, ByRef $sFileName, ByRef $sExtension) $sFilePath = StringRegExp($sFilePath & " ", "^((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*?[\/\\]+)?([^\/\\]*[\/\\])?[\/\\]*((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1) $sDrive = $sFilePath[1] $sFilePath[2] = StringRegExpReplace($sFilePath[2], "[\/\\]+\h*", "\" & StringLeft($sFilePath[2], 1)) $sDir = $sFilePath[2] $sParentDir = $sFilePath[3] $sFileName = $sFilePath[4] $sExtension = $sFilePath[5] Return $sFilePath EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _FileExistsEx ; Description ...: Get New Files Name ; Syntax.........: _FileExistsEx(ByRef $sFilePath[, $iFileExists]) ; Parameters ....: $sFilePath - The Fullpath file ; $iFileExists - Optional ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _FileExistsEx(ByRef $sFilePath, $iFileExists = 0) While FileExists($sFilePath) $iFileExists += 1 $sFilePath = StringRegExpReplace($sFilePath & " ", "( - \(\d+\))?(\.[^\.\\]*)?(\h)$", " - (" & $iFileExists & ")$2") WEnd EndFunc _PathSplitEx.au3
  25. Pleas help me , I am converting HTML to csv using the command stringreg exp. In the example belot, the field Help is not detected. How to change my regexp ? #include <Array.au3> $sString = "<td NOWRAP>cel1</td><td NOWRAP>cel2</td><td NOWRAP>cel3</td><td>Help</td><td NOWRAP>cel4</td>" $aReturn = StringRegExp($sString, '(?s)(?i)<td NOWRAP>(.*?)</td>', 3) _ArrayDisplay($aReturn) thnx.
×
×
  • Create New...