Jump to content

Search the Community

Showing results for tags 'regular expression'.



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

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 17 results

  1. Hello, I'm trying to match the second to last line of this: foo C:\ foobar foobar x C:\temp\dir Last line with chars Here's my code: $test = 'foo' & @CRLF $test &= 'C:\' & @CRLF $test &= 'foobar' & @CRLF $test &= 'hello' & @CRLF $test &= 'C:\temp\dir' & @CRLF $test &= 'Last line with chars' & @CRLF $test &= @CRLF $test &= @CRLF $result = StringRegExp($test, '(?m)^C:\\.*$Last.*') MsgBox(0, '', $result) I'm trying to match line "C:\temp\dir". Anyone have any ideas?
  2. This is a program that I made to help my self learn better regular expressions. There are a lot of other programs/website with the similar functions. But the main advantage of this program is that you don't have to click a button after every changes. The program detected changes and react on it. Function: Match Match of arrays Match and replace Load source data from website Load source data from a website with GET/POST Load text data from file Clear fields Export and Import settings (you can finish the expression a other time, just export/import it) Cheat sheet Generate AutoIt code The source code is not difficult and I think most user will understand it. In the zip file there are 2 export files (POST and a reg back example), you can drag and drop these files on the gui to import them. Download Regex Toolkit Regex toolkit.zip (Sourcode, exmaple and exe file) EDIT: Updated to version V1.2.0 Changes are: Expand and collapse of the cheat sheet (Thanks to Melba23 for the Guiextender UDF) Usefull regular expressions websites links included in the program Text data update time EDIT: Updated to version V1.3.0 Changes are: Automatic generate AutoIt code Icons on the tab Few minor bug fixes EDIT: Updated to version V1.4.0 Changes are: Link to AutoIt regex helpfile If the regular expression has a error than the text becomes red Option Offset with Match and array of Matches Option Count with Match and replace Some small minor bug fixed EDIT: Updated to version V1.4.1 Changes are: Small bug in "create AutoIt" code fixed
  3. I'm looking for a regex genius, cus I'm stumped when it comes to assertions. So what I have now, is this regular expression: ([^|=]+)=([^|]+) It takes a string (user input) of keys=values separated by pipes (ie: "param=value|param=value") and splits them into an array. Example: $vParamData = 'example=value|fruit=apple|phrase=Hello world' $aRegEx = StringRegExp($vParamData, '([^|=]+)=([^|]+)', 3) ; Result ; [0] => example ; [1] => value ; [2] => fruit ; [3] => apple ; [4] => phrase ; [5] => Hello world So that's working fine, but I'm wondering if there's also a way I could have this capture escaped pipes instead of splitting by them. ie: $vParamData = 'pipe test=this \| is a pipe|example=value' $aRegEx = StringRegExp($vParamData, '([^|=]+)=([^|]+)', 3) ; I'm getting this: ; [0] => pipe test ; [1] => this \ ; [2] => example ; [3] => value ; But I'd like a result like this: ; [0] => pipe test ; [1] => this \| is a pipe ; [2] => example ; [3] => value Is there some pattern that would accomplish this, or am I better off parsing it some other way?
  4. regex and iso escape sequences Hi, I would like to extract all ISO escape squences embedded in a string and separate them from the rest of the string, still keeping the information about their position, so that, for exemple, a string like this one (or even more complex): (the string could start with normal text or iso sequences) '\u001B[4mUnicorn\u001B[0m' should be 'transformed' in an array like this $a[0] = '\u001B[4m' ; first iso escape sequence $a[1] = 'Unicorn' ; normal text $a[2] = '\u001B[4m' ; second iso escape sequence ... and so on (note: the above escape sequence has 'control codes' marked as "\u001B' for the asc "esc" char for exemple and a similar notation is also used for other control chars, but in the real string to be parsed those control chars are embedded as a single byte with a value from 01 to 31). at this link (http://artscene.textfiles.com/ansi/) there are many example of real ANSI text files . searching on the web I've found some possible solutions that make use of regexp to achieve similar purpose, and above some others, the regexp pattern posted in the following link by kfir (https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python) seems to be able to catch a wider range of ISO escape sequences (not only color sequences), but my lack of skills on regexp, prevents me from evaluating and testing such patterns I would be very grateful if some regexp guru could come to my rescue... thanks everybody for reading...
  5. I am trying to identify the window based on the window title and text. The title will be the "erwin DM - filename" It is working till date, but some operating systems our application is displaying window as "erwin DM - [filename]" I tried "erwin DM - *filename*" But this regular expression is not working. Any suggestion? $sModelFile = "C:\Users\Administrator\Documents\My Models\eMovies.erwin" $wdModel = _WinWaitActivate1("erwin DM - "&FileNameOnly($sModelFile),"") Func _WinWaitActivate1($title,$text,$timeout=0);Will Return the window Handler Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) return WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc Func FileNameOnly($sFilePath) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) ;_ArrayDisplay($aPathSplit, "_PathSplit of " & @ScriptFullPath) return $sFileName EndFunc
  6. Hi all, it's been a while since I last used regular expressions and I find myself out of time to experiment with this particular issue, so I throw myself upon your mercy and expertise. I am looking to create a function that will say whether or not a supplied string is a valid UUID or not. Local $sTestF = '4C4C4544-004A-4C10-8054-B7C04F46343' Local $sTestT = '4C4C4544-004A-4C10-8054-B7C04F463432' ConsoleWrite('False = ' & _IsValidUUID($sTestF) & @CRLF) ConsoleWrite('True = ' & _IsValidUUID($sTestT) & @CRLF) Func _IsValidUUID($sUUID) ;[\p{XDigit}]{8}-[\p{XDigit}]{4}-[34][\p{XDigit}]{3}-[89ab][\p{XDigit}]{3}-[\p{XDigit}]{12} ; Test UUID = '4C4C4544-004A-4C10-8054-B7C04F463432' Local $sRegExp = '([:xdigit:]){8}\-([:xdigit:]){4}\-([34])([:xdigit:]){3}\-([89ab])([:xdigit:]){3}\-([:xdigit:]){12}' ConsoleWrite(StringRegExp($sUUID, $sRegExp) & @CRLF) Local $Result = StringRegExp($sUUID, $sRegExp) ConsoleWrite($Result & @CRLF) If @error Then ConsoleWrite('Error: [' & @error & ']' & @CRLF) Return 'False' Else ConsoleWrite('Error2: [' & @error & ']' & @CRLF) Return 'True' EndIf EndFunc In the line under the Function call, you'll see the regex I found to do this from a google search. That was my starting point, and I'm trying to get it to work in Au3 and failing miserably. $sTestF is a known invalid String $sTestT is a known valid String Everything I've tried so far has produced the same results for both. Any help you could provide me is greatly appreciated. Thanks for your time!
  7. I am looking to writing an automation script for converting the following SQL procedure code into VBCode as shown below Example ALTER PROCEDURE [dbo].[firstprocedure] (        @var1 varchar(10),        @var2 varchar(7),        @var3 float )    CONVERSION Public Function firstprocedure(ByVal var1 As String, ByVal var2 As String, ByVal var3 As Integer) As DataSet         Dim ds As New DataSet()         '**************query  with stored procedure**********         Dim CMD As New SqlCommand("GetCountOfTempGramWtsGwByFoodCodeProgressAndNewSequence")         CMD.Connection = GetConnection()         CMD.Parameters.Add("@var1", SqlDbType.VarChar).Value = var1         CMD.Parameters.Add("@var2", SqlDbType.VarChar).Value = var2         CMD.Parameters.Add("@var3", SqlDbType.Float).Value = var3         CMD.CommandType = CommandType.StoredProcedure         Dim adapter As New SqlDataAdapter(CMD)   I will be reading the procedural code from the first file that has to be read and create the VB code by writing onto a new file. My approach is that I need the following information captured in Variables which I can insert later onto the new file as and where applicable. In order to do that I need to extract the following bit of information from the file to be READ Name of procedure : firstprocedure List of Variables : @var1, @var2, @var3 Data Types: varchar, varchar & float What I need help with is extracting the list of variables and data types in separate variables. I am looking to build a Regular Expression which I can use to achieve the same. I tried making use of StringSplit function delimited on spaces(" ") but that did not work when reading the file from notepad. I reckon it does not detect spaces in the file. Please help me with the RegExp. Any other suggestions on how best to go about doing this conversion are also welcome. Thank You
  8. Hi all. I'm revisiting poorly commented code of mine from over a year ago. In one line I search a string for a regular expression and cannot figure out exactly what the code is searching for. The expression is: .+(?>\R) I've tried to piece it together from the StringRegExp() page. My educated guess is that it searches for newline characters in some capacity. Here is what I have so far: (?>\R): The (?>...) indicates an atomic non-capturing group, meaning in-part that string matches are not recorded for later reference. I'm not sure what the 'atomic' means though. The description says that this 'locks,' which I'm also unclear on. The \R matches any (Unicode) newline character. So is this component somehow searching for new lines? .+: I'm not sure how these are modifying the above, nor exactly how they work together. The . matches any single character except newline characters, unless (/S) is active. How can I check if /S is active? Would it be a parameter set in one of my options files? And the + seems to match 1 or more. This seems to make the preceding . redundant? The complete line of code is: $aArray = StringRegExp(_IEBodyReadText($oIE2), '.+(?>\R)', 3) I'm reading body text from an HTML page. I can successfully print out each element of this array. Each element contains one line of text, followed by a blank line. Hopefully that helps to confirm things. Thanks in advance.
  9. mikell ;Global $sCharAllowed = ";!#$%&'()+-,.0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{ }~" Local $uStringIN = "頹-衙-浳-浤-搰-橱-煪๏๐๑๒๖D๚๛ẀẁẂẴẵẶặẸẹẺẻỈỉỊAịỌÆ¢™®¯ÌÍÎÏÐÑ×ØÙòóôŘřŢţŷOŸǾǿ₪₫€℅l№™Ωe⅛∑-•v8∫˜≠==□ּׂאַאָאּבּVגּדּהּוּזטּיּךּכשּתּוֹבֿכֿפֿAﭏﭽﮊﮋﮏﮐﮑﮒﮓﮔﺅﺆﺇTﺈﺉﺊﺋﺛﺜﺝﺮﺯﺰﺱﻐRﻑﻒﻓﻔﻕﻟﻠﻡﻢﻣﻤOﻥﻦﻧﻨﻰﻱﻲﻳﻴﻵﻶNﻷﻸﻹﻺﻻﻼْ%-㍱G-煱-둻-睤-㌹-" Local $lStringOUT = StringRegExpReplace($uStringIN, '[[:^print:]]', "_") ConsoleWrite($lStringOUT&@CRLF) jguinch Global $sCharAllowed = "\w;!#$%&'\(\)+,-.=@\[\]^`{ }~" Local $uStringIN = "頹-衙-浳-浤-搰-橱-煪๏๐๑๒๖D๚๛ẀẁẂẴẵẶặẸẹẺẻỈỉỊAịỌÆ¢™®¯ÌÍÎÏÐÑ×ØÙòóôŘřŢţŷOŸǾǿ₪₫€℅l№™Ωe⅛∑-•v8∫˜≠==□ּׂאַאָאּבּVגּדּהּוּזטּיּךּכשּתּוֹבֿכֿפֿAﭏﭽﮊﮋﮏﮐﮑﮒﮓﮔﺅﺆﺇTﺈﺉﺊﺋﺛﺜﺝﺮﺯﺰﺱﻐRﻑﻒﻓﻔﻕﻟﻠﻡﻢﻣﻤOﻥﻦﻧﻨﻰﻱﻲﻳﻴﻵﻶNﻷﻸﻹﻺﻻﻼْ%-㍱G-煱-둻-睤-㌹-" $replace = StringRegExpReplace($uStringIN, "[^" & $sCharAllowed& "]", "_") MsgBox(0, "", @CRLF & $replace & @CRLF)
  10. I wrote a program to convert single and double quotes to curly single and double quotes. The program uses regular expression search and replaces to swap the straight quotes to their curly counterparts and to ignore any HTML tags, too. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> Func Curlify($sInput) Local $sOutput = StringRegExpReplace($sInput, "'(?!([^<]+)?>)", "’") $sOutput = StringRegExpReplace($sOutput, "((^|\s+)(<[^>]*>)*)’", "${1}‘") $sOutput = StringRegExpReplace($sOutput, '"(?!([^<]+)?>)', "”") $sOutput = StringRegExpReplace($sOutput, "((^|\s+)(<[^>]*>)*)”", "${1}“") ; Fix nested quotes While StringRegExp($sOutput, "(‘|“)(<[^>]*>)*(’|”)") $sOutput = StringRegExpReplace($sOutput, "((‘|“)(<[^>]*>)*)’", "${1}‘") $sOutput = StringRegExpReplace($sOutput, "((‘|“)(<[^>]*>)*)”", "${1}“") WEnd Return $sOutput EndFunc ;==>Curlify $FormCurly = GUICreate("Form_Curly", 708, 439, 192, 124) $Original = GUICtrlCreateEdit("", 0, 0, 305, 433) GUICtrlSetFont(-1, 9, $FW_NORMAL, 0, "Courier New") ; Set the font of the previous control. GUICtrlSetLimit(-1, 1500000) $Modified = GUICtrlCreateEdit("", 408, 0, 297, 433) GUICtrlSetFont(-1, 9, $FW_NORMAL, 0, "Courier New") ; Set the font of the previous control. GUICtrlSetLimit(-1, 1500000) $Curly = GUICtrlCreateButton("Curly", 320, 64, 75, 25) $Reset = GUICtrlCreateButton("Reset", 320, 164, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Curly GUICtrlSetData($Modified, Curlify(GUICtrlRead($Original))) Case $Reset GUICtrlSetData($Original, "") GUICtrlSetData($Modified, "") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd So why am I posting a question about a program that works? This regex: $sOutput = StringRegExpReplace($sOutput, "((^|\s+)(<[^>]*>)*)’", "${1}‘") should be able to be rewritten without the "+": $sOutput = StringRegExpReplace($sOutput, "((^|\s)(<[^>]*>)*)’", "${1}‘") Same goes for the one to do double quotes, obviously. However, if I remove the "+" from the "\s" in the regex, the program will fail in some cases. Something like <b>’<i>Don’t</i>’</b> at the beginning of a line won't get fixed. I suspect it's got something to do with the fact the the previous character (aside from the HTML tags) is a newline. The "\s" should work just fine with newlines. I'm stumped because the regex without the "+" modifier works fine on http://www.regextester.com/ when I test it.
  11. Hi, I don't understand why this expression is not lazy: $path = "some\path\that\annoys" ConsoleWrite(StringRegExpReplace($path, "\\.+?$", "", 0) & @CRLF) I'm trying to delete just "annoys" but the regexp matches "paththatannoys"
  12. 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".
  13. 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>ressi&#111;ns. 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
  14. :idea:Someone should figure out an easier way to match things than using regular expressions. I need some help matching things -- I can't seem to get my regular expressions to work. So here is what I am trying to do: Basically, I want to have just the hilighted parts extracted. I am trying to match them using "N100 (" and "(STARTMOP)" and "(ENDMOP)" to define what to extract, but I am having trouble getting a regular expression that matches anything - I just get errors Can anyone help? (BTW, I am using GEOSoft's PCRE Toolkit to test my regular expressions)
  15. I want to remove all characters in a string, from an Asterisk to the end of the string, but the End Of Line regular expression character ('$') does not work for me. $pat = "[*]$" consolewrite("+++: " & StringRegExpReplace("D:\Temp\File.txt * 2abc def" ,$pat, "") & @CRLF $pat = "[*]" consolewrite("+++: " & StringRegExpReplace("D:\Temp\File.txt * 2abc def" ,$pat, "") & @CRLF results in: +++: D:\Temp\File.txt * 2abc def +++: D:\Temp\File.txt 2abc def I expected the first result to be: "+++: D:\Temp\File.txt " (The second result just removed the Asterisk, as I expected.) I tried \z and \Z, but they didn't work either.
  16. Could someone make a pattern for this. Been testing out various patterns for hours. String <div class="profName"><a href="ShowRatings.jsp?tid=1632499">Abaquita, Edwin</a></div> My Pattern (?<=\QShowRatings.jsp?tid=\E).*(?=\Q</a></div>\E) I just need the name (Abaquita, Edwin). The problem with my pattern is the link number (1632499) changes with every name and there are multiple names on a page, also the number of digits varies with each name. Thank you in advance.
  17. _DOSWildcardsToPCRegEx (+GUI) While I've posted an earlier version of this elsewhere (I will redirect to here don't worry), I figured I might as well provide a GUI interface to expose what this function does and returns, and allow its results to be copied/pasted elsewhere (like to AgentRansack, a free file-search tool supporting PC Regular Exp​ressions). So here you'll find both the GUI interface and the UDF itself. What it does: Takes a DOS wildcard exp​ression (ex: '*.*','*.jp*g','logfiles.l?g') and converts it into a PC Regular Exp​ression. This function in its original form, _FileMatch() was originally created by RobSaunders. I altered it a bit so that it will match files just as a 'Dir' command would. It has the potential to be used for other types of comparisons as well, but you'll need to understand that it's results will probably need to be tweaked for whatever your intentions are. If you'd like to experiment with it's results, you can try using the String Regular Exp​ression Tester (by Szhlopp), the RecursiveFileSearch (#1 version) (by WeaponX) function (which is the reason I initially worked on it), or like mentioned above, AgentRansack, a free file-search tool. GUI interface included that does the work for you! Download the ZIP at my Site Ascend4nt's AutoIT Code License agreement: While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I creditIf the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.
×
×
  • Create New...