Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Regular expression tester [Updated]

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,35894
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Regular expression tester [Updated]
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Regular expression tester [Updated] - 6/29/2006 6:44:59 AM   
  mikeock


Posts: 124
Score: 1
Joined: 6/8/2006
Status: offline
At work i am limited to VBS due to the project.

I wrote this lil app for regular expressions through VBS.
A fellow employee did do a lil bit of fixing for the submatch and the global search.

Let me know what you think.
Original

      

Edit: 2006/07/27
And now with all fixes. File loading, GUI enhancements.
App now features tool tips on almost all items.
Added a lot of coloring.
Cleaned out code where possible.
Try it and let me know

      

< Message edited by mikeock -- 7/27/2006 1:29:32 AM >


_____________________________

My sig sucks!
 
 
Revisions: 4 | Post #: 1
 
 RE: Regular expression tester - 6/29/2006 9:16:08 AM  1 votes
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi mikeok,

thanks for your useful script. I had real fun studying it. Perhaps you
are interested in two additions:

(1) I like to test my .HTAs immediately while I'm tinkering with the
    code; .HTMLs can be reloaded using the browser's button, for .HTAs
    I usually add a button and this reloadHTA() Sub.
    
(2) There is another RegExps property that was undocumented for a long
    time and frequently misunderstood: Multiline. The new VBScript Docs
    mention it for JScript only - so perhaps you'll learn something
    new.

Additions:

      
I think it shows the quality of your code that another programmer could
understand and add to your script in such a painless way. I hope you will
like my additions as much as I liked your "Regular expression tester"

ehvbs
 

(in reply to mikeock)
 
 
Post #: 2
 
 RE: Regular expression tester - 6/30/2006 1:44:27 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
Not to diminish the contribution of very well written and useful code, but there is a regular expression testing extension for Firefox that I use all the time when I need to come up with a weird pattern.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: Regular expression tester - 6/30/2006 2:13:23 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi ebgreen,

you are right and I thank you for the pointer to Sebastian Zartner's Regular Expressions Tester.
But after using this (or any other non VBScript based tool), you'll still have to check with mikeok's
script, whether the results in your VBScript will be the same! Just use the MultiLine feature as
a test case, you'll be surprised!

ehvbs

(in reply to ebgreen)
 
 
Post #: 4
 
 RE: Regular expression tester - 6/30/2006 3:59:24 AM   
  mikeock


Posts: 124
Score: 1
Joined: 6/8/2006
Status: offline
Thanks for the input!
I will look at rolling the those other options into this.

_____________________________

My sig sucks!

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Regular expression tester - 7/6/2006 5:35:02 AM  1 votes
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
Thanks for this regex tester, it's much easier to use than some of the others I've tried and it is vbs specific for some stuff.

I have already merged it and cleaned it up a little bit, the code is below.

also ehvbs, it is difficult to copy and paste your stuff with the line numbers included ;)

Suggestions:
Check for "preceding" symbols such as the * symbol, it created an error when I searched for *test in testing
Add in functionality for the replace method, this would be nice to have.



      



_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to mikeock)
 
 
Post #: 6
 
 RE: Regular expression tester - 7/6/2006 5:57:24 AM   
  mikeock


Posts: 124
Score: 1
Joined: 6/8/2006
Status: offline
Nice. I was acutally in the process of rolling the new settings in when I saw your post.

Thanks! Saves me a bit of time.

What exactly does the Multiline funtion do?

I see that it can be enabled but do we need to call against or just enabl it to see the difference?

_____________________________

My sig sucks!

(in reply to kirrilian)
 
 
Post #: 7
 
 RE: Regular expression tester - 7/6/2006 6:55:07 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi mikeok,

Straight from the VBScript Docs:

If multiline is false, "^" matches the position at the beginning of a string, and "$" matches the position
at the end of a string. If multiline is true, "^" matches the position at the beginning of a string as well
as the position following a "\n" or "\r", and "$" matches the position at the end of a string and the position
 preceding "\n" or "\r".


Hi kirrilian,

sorry about the inconvenient line numbers, but

   (1) I wanted to mark the positions in mikeok's code clearly where my proposed additions
         should be added

   (2) If your editor doesn't have a column mode, you can always use my (transfor)mator
         tool to add/remove line numbers painlessly.

ehvbs

(in reply to mikeock)
 
 
Post #: 8
 
 RE: Regular expression tester - 7/6/2006 6:56:07 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
all you have to do is check the box,

      If ExprStrin.MultilineCheckBox.checked Then    'Set Multiline attribute according to checkbox
            Re.Multiline = True
        Else
            Re.Multiline = False
        End If

however, im not sure what the multiline flag does though.

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to mikeock)
 
 
Post #: 9
 
 RE: Regular expression tester - 7/6/2006 7:14:09 AM   
  mikeock


Posts: 124
Score: 1
Joined: 6/8/2006
Status: offline
ehvbs,


Thanks for the explanation. It looks a lot like what you would see in other langauges and makes alot more sense now,

_____________________________

My sig sucks!

(in reply to kirrilian)
 
 
Post #: 10
 
 RE: Regular expression tester - 7/6/2006 7:23:54 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi mikeok,

your are welcome. By the way - what do you think about adding some persistency to your
Regular expression tester? It would be great, if you could save RegExps, options, test data,
and comments/explanations -  perhaps even post samples here, that could be loaded
and studied.

ehvbs (just starting to dream)

(in reply to mikeock)
 
 
Revisions: 1 | Post #: 11
 
 RE: Regular expression tester - 7/6/2006 7:26:23 AM   
  mikeock


Posts: 124
Score: 1
Joined: 6/8/2006
Status: offline
That is an intersting idea... I think that would be very cool and the tool would become that much more robust.....
Maybe you could use a txt file that has everything in a certain order, click load from hta and all of the fields are auto filled out?

Dunno just throwing out ideas seeing what others think!

_____________________________

My sig sucks!

(in reply to ehvbs)
 
 
Post #: 12
 
 RE: Regular expression tester - 7/6/2006 8:04:58 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
could one of you share what the multiline flag does?

it seems to be poorly documented...

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to mikeock)
 
 
Post #: 13
 
 RE: Regular expression tester - 7/6/2006 9:32:48 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Start a version of mikeok's .hta with the multiline code added. Enter RegExp
   ^a
(looking for an "a" at start) and the test data
   a
   b
   a
   b
Enable Global and Test: one match (the first "a", because the second one isn't at the
start). Activate Multiline and Test: two matches, because now the ^ means "at the
start of the whole string and at the start of each line (af