RegExstar - Tool for Regular Expressions

Post your working scripts, libraries and tools
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

RegExstar - Tool for Regular Expressions

09 Feb 2016, 03:01

RegExstar - Tool for Regular Expressions
Hope you enjoy guys! Feedback is appreciated. :thumbup:
I have found it to be quite useful. Teacher gives an assignment, "write some javascript to validate that input is a state abbreviation." So I get on google, copy the states with their abbreviation, use RegExstar m).*?(?=[A-Z]{2}) to get just the Abbreviations, and then needle `n replace | and presto it is ready to go into a javascript regex. (Using RegEx's to create other RegEx's crazy I know :lol: ) Hopefully you will find it useful too.

Versions:
  • 2/9/2016 RegExstar 0.9 - Beta Release

    2/10/2016 RegExstar 0.9.1 - Added listbox containing all the regex matches. Changed the Pattern Edit control to a listbox control. Switched out replace checkbox in favor of a clickable count label. RegExstar 0.9.1.1 - Bug Fix

    2/12/2016 RegExstar 0.9.2 - Added Toolbox of Regular Expressions. Increased Font Size of Regular Expression Needle. Added support for multiline option. Various other Bug Fixes and changes.

    2/14/2016 RegExstar 0.9.3 - Added window resizing.

    2/16/2016 RegExstar 0.9.4 - Added Debugger

    2/17/2016 RegExstar 0.9.4.1 (Current) - Multiline Needle and Floating Toolbox.
Download from GitHub - RegExstar - An AHK Tool for Regular Expressions
View Source Code - RegExstar - An AHK Tool for Regular Expressions
-Tested on Windows 10-
Last edited by wizardzedd on 22 Feb 2016, 11:13, edited 10 times in total.
User avatar
boiler
Posts: 2622
Joined: 21 Dec 2014, 02:44

Re: RegExstar - Tool for Regular Expressions

09 Feb 2016, 20:08

Hey, good work. I think this should be a handy tool. There are some online tools that have some more features, but they are often limited in what they support. For example, regexr is pretty slick, but it doesn't support things like look-behinds, which I find myself using a lot. It seems like this should support anything and everything that will work in an AHK script. Thanks for sharing it.

My only suggestion so far is that I think it would be better for the default to be in match mode rather than replace, because when I'm testing my expression, I don't want it to be cutting pieces out of my sample haystack. I would just like to see where it finds matches. That is how it seems most useful to me when debugging an expression. I don't need to see it replace. I just want to see it match the needle in the haystack, and then I can decide whether I want to use that expression for a match or replace or whatever.
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

Re: RegExstar - Tool for Regular Expressions

09 Feb 2016, 23:06

boiler wrote:It seems like this should support anything and everything that will work in an AHK script. Thanks for sharing it.
Glad to hear it :)
boiler wrote:My only suggestion so far is that I think it would be better for the default to be in match mode rather than replace
The default will be whatever it was last set to except for the first time opening, since it saves the state in the init file.
kunkel321
Posts: 176
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Re: RegExstar - Tool for Regular Expressions

13 Feb 2016, 10:07

Very cool tester! Thanks for sharing! It's nice that it is specific to AHK. I'm still new to ahk/regex/coding and the differences between regex flavors is yet another thing that confuses. So the ahk tie-in is nice.
As indicated on my other thread that you helped with, I've been assigning regex's to variables, then using the variables in my expressions... Here's an example of using the assigning the regex to a variable, then using the variable in an additional regex. (which then gets used in an expression.)
===========================
reWDay := "\b((Mon|Tue(s)?|Wed(nes|s)?|Thu(rs|r)?|Fri|Sat(ur)?|Sun))(day|d)?\b"
reMonth := "\b((Jan|Feb)(ru(ary)?)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|(Sep(tem)?|Oct(o)?|Nov|Dec)(em)?(ber)?)\b"
reLoc := "(((room|rm)|(in\K)|((in\s\K)(room|rm)))\s\d{3})|((1st|first|2nd|sec(ond)?)"
. "\sfloor\s(counseling|conf(erence)?))|((Smiling)?\sFloyd(s|'s)?\s)"

reName := "(?!(" reWDay "|" reMonth "|" reLoc "))\b[A-Z][a-z]*\s[A-Z]([a-z]*)?([A-Z][a-z]*)?\b"
==========================
I've not found a regex tester (ahk-based, or otherwise) that can test this. Might be interesting to add. I also suggested this to the AutoGUI guy.

Anyway, thanks again.
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

Re: RegExstar - Tool for Regular Expressions

16 Feb 2016, 22:58

Updated to RegExstar 0.9.4
Now includes a step by step debugger! Thanks to the RegExCallout feature that made this possible. Suggestions and improvements are always welcome.
ImageImage
kunkel321
Posts: 176
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 09:29

Wow very cool!
On my Dell laptop, there is a really small DPI. I think my system font setting is a bit increased (though I don't remember increasing it myself). I find that some apps have text that runs of the edge of the dialog. This is especially noticeable with RegExstar's Toolbox (see image)
Image

Is it possible to make it float like the others?

Also notice the error message.
Actually, I see now that that is the debugger working correctly! :thumbup:

I do recommend making the needle edit box with a bit smaller text, and at least three lines high...
Also, the list of matches is awesome, but there's no substitute for having the sample haystack text highlighted in-place. I suppose Autohotkey probably doesn't support this out of the box though...
User avatar
BGM
Posts: 464
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 11:36

Can you add syntax colouring for the needle? I have always dreamed of a regex editor that could do this.
kunkel321
Posts: 176
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 14:04

I think space characters might be getting stripped from my haystack text...
Paste this in:
----------------------
Maybe next Tue?
Or next Friday? ; is OL friendly
Next week Mon.
Next week Montgomery Burns will visit.
Wednesday after next
After school next Thurs.
Before school, I guess.
2 weeks Wed
This Thursday.
Stephen K
THe 4th of March.
Seth MacFarlane
Feb 11.
2-1-2016
2/1/16
Meeting for John Doe.
--------------------

Then when I close and re-open RegExstar, it looks like this:
--------------------
MaybenextTue?
OrnextFriday?;isOLfriendly
NextweekMon.
NextweekMontgomeryBurnswillvisit.
Wednesdayafternext
AfterschoolnextThurs.
Beforeschool,Iguess.
2weeksWed
ThisThursday.
StephenK
THe4thofMarch.
SethMacFarlane
Feb11.
2-1-2016
2/1/16
MeetingforJohnDoe.
------------------
User avatar
boiler
Posts: 2622
Joined: 21 Dec 2014, 02:44

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 14:56

BGM wrote:Can you add syntax colouring for the needle? I have always dreamed of a regex editor that could do this.
Like this? Not only does it have immediate syntax and match highlighting, it also describes the element of the needle and haystack matches you are hovering over, and it has a nice interactive reference. The only problem is it doesn't handle look behinds and possibly some other things.

I think those would be great features to add, but I think it would be pretty difficult.

Edit: This one looks like it handles look behinds too.
User avatar
BGM
Posts: 464
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 15:18

yes, like those - but I don't want an online one. Yours is real nice, and I love autohotkey. I've been using one called RegEx Tester by toralf
www.autohotkey.com/forum/topic17844.html
http://www.autohotkey.com/board/topic/1 ... ester-v21/
but they don't have syntax colouring either, that's why I'm asking.
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 15:20

kunkel321 wrote:I think space characters might be getting stripped from my haystack text...
I was using a line of code when trying to debug a problem with different linefeeds which I forgot to take out. (This bug still exists as far as I know. If anyone knows what the problem is let me know =)).
Removed that line of code and the spacing problem is fixed now.
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 15:24

BGM wrote:Can you add syntax colouring for the needle? I have always dreamed of a regex editor that could do this.
Good idea. I will definitely have to dig a little deeper into hiedit or rich edit or something, as the normal edit control will not support multiple colors within a single edit. A challenge for sure but I'll look into it.
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

Re: RegExstar - Tool for Regular Expressions

17 Feb 2016, 15:41

kunkel321 wrote: Is it possible to make it float like the others?
Yes, I'll change it to be like the others. Here I thought I came up with a good solution for autoXYWH for gui with the +parent option, but I guess it only works on my system... There's the downfall of testing on one system only.
I do recommend making the needle edit box with a bit smaller text, and at least three lines high...
I changed it to be larger because I thought it would be nice to have a closer look at the pattern, perhaps I should make it an option? I suppose if I get syntax highlighting it probably won't matter if its large. As far as the 3 lines high thing... I was actually thinking of that myself. ;)
Also, the list of matches is awesome, but there's no substitute for having the sample haystack text highlighted in-place. I suppose Autohotkey probably doesn't support this out of the box though...
Currently I'm limited to highlighting one match at a time, since I'm just selecting the match with the cursor basically. Perhaps I can do something more with the more powerful edit controls. I'll look into it.
kunkel321
Posts: 176
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Re: RegExstar - Tool for Regular Expressions

18 Feb 2016, 14:52

Preserve spacing is fixed but there's a new rogue line code now! LOL
...RegExstar3.ahk (52) : ==> #Include file "C:\Users\Robert\Documents\AutoHotkey\Lib\Log.ahk" cannot be opened.
As you might guess, I commented it out and everything works fine. :)

EDIT: The changes look good! The 3 lines is nice, and the font is still large enough for my old eyes to see. I gotta tryout this toolbox now.... To my knowledge, RegExstar is the only Autohotkey-specific regex tool with builder components! :thumbup:
wizardzedd
Posts: 319
Joined: 23 Jan 2016, 23:03

Re: RegExstar - Tool for Regular Expressions

18 Feb 2016, 15:21

Haha, I need to find a better way to seperate testing from the real version. =D That is my debugger I use. Fixed now!
User avatar
boiler
Posts: 2622
Joined: 21 Dec 2014, 02:44

Re: RegExstar - Tool for Regular Expressions

28 Sep 2016, 22:34

wizardzedd wrote:Currently I'm limited to highlighting one match at a time, since I'm just selecting the match with the cursor basically. Perhaps I can do something more with the more powerful edit controls. I'll look into it.
For what it's worth, njciancio's LiveRegExTester used a Scintilla edit control in order to highlight all matches at once. Unfortunately, it seems the link to the source code is broken. If that could be tracked down, perhaps you could incorporate some approaches from that code into yours.
User avatar
boiler
Posts: 2622
Joined: 21 Dec 2014, 02:44

Re: RegExstar - Tool for Regular Expressions

30 Sep 2016, 18:33

Yes, that's it. Thanks. When I run it, it says there's a non-existent function even though the "includes" folder with the appropriate file in it is there. I'm not going to try to figure it out myself right now.
sancarn
Posts: 224
Joined: 01 Mar 2016, 14:52

Re: RegExstar - Tool for Regular Expressions

31 Dec 2016, 11:41

kunkel321 wrote:I've not found a regex tester (ahk-based, or otherwise) that can test this. Might be interesting to add. I also suggested this to the AutoGUI guy.
Try Regex101.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: jackdunning, kczx3, thebbandit and 35 guests