Sign in to follow this  
Followers 0
Ascend4nt

_DOSWildcardsToPCRegEx

4 posts in this topic

#1 ·  Posted (edited)

_DOSWildcardsToPCRegEx (+GUI)

Posted Image

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 credit
  • If 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.
Edited by Ascend4nt

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Share this post


Link to post
Share on other sites

That is very nice!! Now if you could write it so that it can figure out my regex for every project to know how to parse structures and div's and such from different structures like html and plain text and geesh, I could go on forever.. LOL Very nice job...

Share this post


Link to post
Share on other sites

Thanks guys!

@ptrex, AgentRansack rocks :D , but hmm.. I'd rather buy their FileLocatorPro version than develop my own! Plus there's a few projects here I believe that do searches. Maybe not PCRE searches, but well.. what can you do. I don't think AutoIt is suited for searching text in files though :unsure:

@gseller - Hah, funny. That's actually part of the fun of Regular Expressions - figuring them out! There's actually a few places I can recall that help you build them.. heck, even AgentRansack has a type of expression-builder.. but I've found it more fun to figure them out! Maybe I'm a masochist though :P

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • nend
      By nend
      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 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 The source code is not difficult and I think most user will understand it.
      This program does need the winhttp udf https://www.autoitscript.com/forum/topic/84133-winhttp-functions/ (it's also include in the zip file)
      In the zip file there is also a export file (POST example), this is a example of website source code with POST.
      You can download it here Regex toolkit.zip
       
      EDIT: Updated to version V1.2.0
      Change are:
      - expand and collapse of the cheat sheet (Thanks to Melba23 for the Guiextender UDF) - usefull regular expressions websites links included in the prgram - text data update time
    • nikink
      By nikink
      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!
    • Kyan
      By Kyan
      Hey everyone
      I'm stuck with this regular expression, for matching a iso standard version
      what I want to do is match the text in green: ISO 11784:1996/Amd.2:2010(E)
      there is also others that look like this: ISO 11789:1999(E), and without the (E) part,
      Só I did this one
       (?i)ISO.+?[\d-]+:(?:\d+/Amd.+?:)?[\d-]+(?:\(\w\))* to match both cases but doesn't ignore the text in red
      Can somebody point out what I'm doing wrong here?
       
    • sjaikumar
      By sjaikumar
      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
       
       
    • cag8f
      By cag8f
      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.