Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

String Regular Expression Tester V2


  • Please log in to reply
31 replies to this topic

#1 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 03 September 2008 - 08:27 PM

*
POPULAR

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:
Attached File  SRETesterV2.1.au3   11.41KB   2008 downloads
Prev DL - 211

Enjoy!

Edited by Szhlopp, 10 October 2008 - 04:07 PM.

  • wilburnwlssh, arnulfojynsh, martywvn and 7 others like this







#2 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 04 September 2008 - 04:12 AM

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
  • dewittcfez and jewelluoc like this

#3 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 04 September 2008 - 05:38 AM

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

#4 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,821 posts

Posted 04 September 2008 - 07:43 AM

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 *new

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


#5 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 04 September 2008 - 04:10 PM

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...

#6 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 04 September 2008 - 06:19 PM

I am sure I would use it often!

@ Xenobiologist - I have tried, it just does not make sense past the simple examples. For now, I am destined to beg for regex help on the forum.. LOL

#7 ResNullius

ResNullius

    Drink Deep, or Taste Not the Pierian Spring

  • Active Members
  • PipPipPipPipPipPip
  • 1,033 posts

Posted 05 September 2008 - 01:43 AM

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

#8 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 05 September 2008 - 06:29 AM

Sounds a little like "Regulazy": http://weblogs.asp.net/rosherove/pages/too...y-osherove.aspx



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

#9 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 05 September 2008 - 02:33 PM

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.

#10 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,764 posts

Posted 08 September 2008 - 07:05 AM

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 ;)

#11 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 08 September 2008 - 08:47 PM

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=)

#12 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 10 October 2008 - 04:10 PM

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

#13 Garp99HasSpoken

Garp99HasSpoken

    Adventurer

  • Active Members
  • PipPip
  • 116 posts

Posted 24 October 2008 - 09:44 AM

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


#14 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 24 October 2008 - 04:04 PM

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?

#15 Garp99HasSpoken

Garp99HasSpoken

    Adventurer

  • Active Members
  • PipPip
  • 116 posts

Posted 27 October 2008 - 04:46 PM

Uhm, I have no idea what you're asking....

If Conditional subpatterns are NOT supported by AutoIt or just your program.
I guess it's AutoIt... or my understanding on how to use them.

Your example had nothing to do with Conditional subpatterns.

Help explain?

I thought I did!

#16 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 27 October 2008 - 08:49 PM

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

GeorgeQuestion 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!"

#17 zerobazar

zerobazar

    Seeker

  • Active Members
  • 26 posts

Posted 28 October 2008 - 06:13 AM

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.

#18 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 28 October 2008 - 09:02 AM

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, 28 October 2008 - 10:09 AM.

GeorgeQuestion 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!"

#19 zerobazar

zerobazar

    Seeker

  • Active Members
  • 26 posts

Posted 28 October 2008 - 10:20 AM

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.

#20 SmOke_N

SmOke_N

    It's not what you know ... It's what you can prove!

  • Moderators
  • 15,730 posts

Posted 28 October 2008 - 11:05 AM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users