Jump to content

String Regular Expression Tester V2


Szhlopp
 Share

Recommended Posts

Since there are WAY to many posts on how to SRE something I thought I would create a nice little tester. ;)

This thing does SRE and SRER.

Loads files to test.

Gets internet content to test.

And more!

Here it is:

Prev DL - 14

Enjoy!

Quick update:

Fixed a few bugs.

Added "Notes" tab

Added "AutoIt" tab.

And thanks for the rate! (Whoever did it) :D

Link to comment
Share on other sites

RegEx isn't that hard to learn. Give yourself 1 hour reading and trying and you can do it.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Sweet!! Now if you can release that bot that will come cram REGEX into my brain!! LOL I just don't get it... ;) I can't pull myself out of a wet paper bag using regex... LOL ;)

Funny you mention it...

I actually was thinknig about writing a 'bot'.

You supply it the text:

<Xml>Hey</xml>

Highlight it:

<Xml>Hey</xml>

Press the button and you get some options on how it should be formatted.

The problem is, there are alot of options on some pieces of text. Does it look for:

<xml>(.*?)<

>(.*?)<

<(?:.*?)>(.*?)<

<(?:.*?)>(.*?)</

>(.*?)</

...ect...

As you can see with a very simple string there are a lot of different ways to do it. You would have to have some way programmatically to get the result down. Either by supplying it like 5 cases or just testing it with all the results and then testing the list of patterns again with another case. :D

My only other idea was this. Have a button someplace on the GUI that has a nice list of the commands (Currently 'help!'). The commands you could just double click/insert and every command would have an example of how/why it works.

This way would teach the user more than just using the process of elimination. Still don't know if it would be worth all the time in doing...

Link to comment
Share on other sites

Funny you mention it...

I actually was thinknig about writing a 'bot'.

You supply it the text:

<Xml>Hey</xml>

Highlight it:

<Xml>Hey</xml>

Press the button and you get some options on how it should be formatted.

Sounds a little like "Regulazy": http://weblogs.asp.net/rosherove/pages/too...y-osherove.aspx
Link to comment
Share on other sites

I downloaded it and will have to sit down with it.. Thanks.. Still waiting for Szhlopp's BOT.. LOL ;)

Meh, that isn't close to the top of my list... :D

May mess with it a little after I put 4.2 out of the olympcs.

Link to comment
Share on other sites

Is there any way to add highlighting of matched terms in the text/file view?

Thank you very much, btw, it's saving me a ton of work formatting data for a database ;)

Link to comment
Share on other sites

Is there any way to add highlighting of matched terms in the text/file view?

Thank you very much, btw, it's saving me a ton of work formatting data for a database ;)

Welcome.

Highlighting the text found in the text/file tabs?

Hey

Test

1 more word

Pattern: more

'more' lights up?

Interesting... Yeah I might be able to do something like that with a re-work and a good RTF UDF. I may look into this=)

Link to comment
Share on other sites

  • 1 month later...

Quick update on the SRE tester.

Added control tips to the radio's.

Fixed an issue with the "Text" tab having a very small limit(Now 1000000).

Added a comment line inside the script to thank w0uter for the original GUI layout.

:P

Link to comment
Share on other sites

  • 2 weeks later...

CONDITIONAL SUBPATTERNS

It is possible to cause the matching process to obey a subpattern conditionally or to choose between two

alternative subpatterns, depending on the result of an assertion, or whether a previous capturingsubpattern

matched or not. The two possible forms of conditional subpattern are

(?(condition)yes-pattern) or (?(condition)yes-pattern|no-pattern)

If the condition is satisfied, the yes-pattern is used; otherwise the no-pattern (if present) is used.

If there are more than two alternatives in the subpattern, a compile-time error occurs.

I was trying this out with your program but could not get anything working.

Is it your program that ignores this or is it AutoIt which does not implement this part of regexp?

Sample input 11:34:26 and 6:48:32 where I want the second to have the 6 zero filled and the seconds removed

From

(\d)?(\d):(\d)?(\d):\d\d
to
(?(1)\1|0)\2:(?(3)\3|0)\4

output is

(?(1)1|0)1:(?(3)3|0)4
(?(1)|0)6:(?(3)4|0)8

but should be
11:34
06:48
Link to comment
Share on other sites

I was trying this out with your program but could not get anything working.

Is it your program that ignores this or is it AutoIt which does not implement this part of regexp?

Sample input 11:34:26 and 6:48:32 where I want the second to have the 6 zero filled and the seconds removed

From

(\d)?(\d):(\d)?(\d):\d\d
to
(?(1)\1|0)\2:(?(3)\3|0)\4

output is

(?(1)1|0)1:(?(3)3|0)4
(?(1)|0)6:(?(3)4|0)8

but should be
11:34
06:48
Uhm, I have no idea what you're asking....

All my program does is add a GUI to the AutoIt function "StringRegEx". The version of AutoIt you're using is also the version my script uses(unless you compile it).

Conditional Subpatterns work like this:

Text:

Hello You
Hello Me
Hello Myself

Flag: 3

Pattern:

(?i)Hello\s?(?:You|Me)

(?i) Insensitive flag

"Hello" - Text to find

\s? - Space may or may not appear

(?: - Non capturing group

You|Me - Finds either "You" or "Me"

) - End group

Help explain?

Link to comment
Share on other sites

"(\d*:\d*):"

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Garp99HasSpoken, AutoIT is using PCRE engine for regex.

PCRE is supporting/implementing conditional subpatterns so there should not be any problem to use them with AutoIT.

But coming back to the GUI proposed by Szhlopp, what it does, is to give you an easy way to test regex without coding script (a bit like RegexBuddy). It helps you to test one regex at time.

Now coming back to your example, I do not understand how it can achieve what you expect in one regex?

Can you explain how you would use it within one regex (only)?

I'm quite new at these regex, but willing to learn.

Thanks.

Best regards.

Link to comment
Share on other sites

Garp99HasSpoken, AutoIT is using PCRE engine for regex.

PCRE is supporting/implementing conditional subpatterns so there should not be any problem to use them with AutoIT.

But coming back to the GUI proposed by Szhlopp, what it does, is to give you an easy way to test regex without coding script (a bit like RegexBuddy). It helps you to test one regex at time.

Now coming back to your example, I do not understand how it can achieve what you expect in one regex?

Can you explain how you would use it within one regex (only)?

I'm quite new at these regex, but willing to learn.

Thanks.

Best regards.

With what he was doing there was no need for a conditional so I just gave him the RegExp in my reply. What that says is; get a digit 0 or more times then the colon then digits 0 or more times again and stop at the next colon. Since none of the characters can be case sensitive I didn't need (?i). It could also heve been written as (?i)(\d*[h:]\d*): which would also allow for those people who have an h as the Hr/Min separator instead of a colon. If it was being used in a StringRegExpReplace situation I would probably use something like (\d*):|h(\d*) as in

$sStr = StringRegExpReplace($sStr, "(\d*):|h(\d*)", "\1:\2") Which would also make sure that the return was 06:48. (Group 1 and colon and group 2)

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

GEOSoft,

I can not make to work any of the example you provide...

Based on your first proposal, some thing like:

$sStr = StringRegExpReplace($sStr, "(\d*:\d*)(:.*)", "\1")

would be closer (to remove seconds), but is still missing the requirement to have a zero filled at the beginning when you have 6:48:32->06:48

In fact, the first regex

(\d)?(\d):(\d)?(\d):\d\d

Garp99HasSpoken was suggesting is ok to match expressions like 11:34:26 and 6:48:32 but that's the second part I would like to understand...

To work it would need to be "run" within the same regex expression (because there are backreferences to group 1,2,3 and 4) but I feel there is a problem with the use of conditional in this case (at least in the way I understand them).

Best regards.

Link to comment
Share on other sites

  • Moderators

GEOSoft,

I can not make to work any of the example you provide...

Based on your first proposal, some thing like:

$sStr = StringRegExpReplace($sStr, "(\d*:\d*)(:.*)", "\1")

would be closer (to remove seconds), but is still missing the requirement to have a zero filled at the beginning when you have 6:48:32->06:48

The simple explanation for 1 expression is .... you can't.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...