last day (61 days later) » 

1:14 AM
Hey bro, good timing, just starting to answer questions now... How was your day, you must be dog-tired?
 
I'm good man, thanks for the upvotes =) and actually I took a nap mid-day for a few hours so I feel refreshed
 
Love naps. So refreshing. So are you saddling up for nine hours on Stack? :)
 
I'm actually trying to rewrite the regex::explain Perl module to handle recursive explanations, but it's being a pain in the butt =)
Because the module doesn't explain recursive such as (?R) or (?1) (?-1) and so on..
So far I add explanation for \R though, liveforfaith.com/re/explain.pl?re=%5CR&.submit=Explain%21
 
Yeah I bet. So rick.measham.id.au is not your site? I saw that you are using the same explanations and wondered if you were wrapping his output, or if you had rewritten it.
 
I have been rewriting/reformatting it, this is the one I implemented liveforfaith.com/re/explain.pl
 
1:21 AM
Yes, your output looks good. So that means you are writing your own parser?
 
Yea in a way.
 
Why "in a way"?
 
Well I am extending the module's code by adding to it and implementing different formatting
 
Hey by the way another one that I noticed is missing from Rick's site is \K, I see that you have the same gap.
But the whole task of writing an EXPLAIN is so bloody hard because one token in different flavors means different things!
Oh, how did you get the module's code?
 
1:24 AM
different flavors means different things for instance Ruby and (?m) ... lol
Or \d in .NET, php...
Or balancing groups...
Or the fact that (?R) will not work in .NET (c'mon Msoft wake up)
 
Yea, that's why it's gonna take me a week to rewrite this to handle mainly PCRE
 
PCRE? Wow, brilliant!!!
User-friendly-wise, since you say you want to make it easy to paste on SO, you could have a 'Copy' button, with text that is already incremented by 4 spaces, and separate the comments with a #... Or just make that your own private secret weapon. :)
 
Hmm good idea..
 
I have a question for you. Are you good at compiling bits of C++ code found floating around for Windows?
I found a promising regex tool, but can't get it to compile properly.
 
Honestly, never really worked in c++ but I'm sure I could figure it out.
Is this what you mean for the \K gap? liveforfaith.com/re/explain.pl?re=%5CK&.submit=Explain%21
 
1:32 AM
Yeah, I don't know C++ either... But I don't think it's a matter of knowing C++, it's a matter of knowing the tools and the 15 hoops you have to jump through to make something work. I compiled it using g++ as instructed, and it compiles fine, but it doesn't run.
Hey, a whole heap of \K coolness... Well-done, dude. :)
 
Bookmark this regex-explain site if you want, I'll work on the formatting to make it easier to paste an explanation for faster answering =)
 
Not only is it bookmarked, it's added to the search bar. :)
`I'll work on the formatting` Brilliant, otherwise I need to wrap the output in a macro. :)
Hey I'm starving, need to step away for lunch.
afk
 
2:23 AM
@hwnd Back.
So one thing escapes me. You sent me that cpansearch link. But how did you even hear about that? How does something like that come across your radar? It sounds so obscure, buried in the deep-web...
 
I mainly program in Perl, so I always cross reference different modules
 
I see...
 
Hey do you like this better to where you can copy the text from a textarea box? Also I indented by 4 spaces, so you can copy and paste!!
Plus you can drag the textarea
 
Yes, that's terrific. I'll start using it so I can give you feedback... but you have to tell me if it's too much feedback! :)
 
I used the following to replace the beginning spaces
$regex_explain =~ s/^(?!^$) {2}/ /gm;
 
2:29 AM
Yeah I did something like that in my macro, but I also inserted #es. Let me look...
Search: (?m)^.{2}(.{25})
 
Or did you like the other <pre><code> block of format better?
 
Replace: $1#
> Or did you like the other
For me, the textbox is great. But hey, you can have a GET in your URL and offer the two modes. Maybe the regular <code> for normal people who just want to look at it, and people like us you want to post on SO use a different url,
http://liveforfaith.com/re/explain.pl?mode=stack&etc
explain.pl?mode=stack&etc
 
hmm yea I could do that
 
If you go that way, you could add more GET parameters.
Or add some features that only matter to SO people. For instance, I would like to
1. specify the title at the top, in particular I want it to be bold, so instead of `Regular Expressions:` I would use something like &title=**Explain%20Regex**
2. have a comment # before the explanation, as in the regex I sent you.
So &comment=true
I warned you about too much feedback :)
 
So one format like this? liveforfaith.com/re/…
 
2:38 AM
Easier on the eyes, but harder to copy-paste... That could be the default, but for people who know your GET syntax, we can tweak the url to get the textbox.
Because we would bookmark the url with the correct GET string, we would always get the page we want: explain.pl?mode=stack&comment=true&title=**Explain%20Regex**
 
Hmm sounds good to me, Ill see what I can do while I wait on questions to arise lol
 
Btw is it easy to parse the GET variables in Perl? In php as you know they're all in the $_GET array, like $_GET['mode']
 
Yea we use for example:
my $q = CGI->new;
if ($q->param('mode') eq 'Stack') { ... }
 
Oh that's alright. Is it easy to test if the variable is not set?
 
Yea, if not defined ($q->param('mode')) { ... }
or if (!defined $q->param('mode')) { ...
 
2:45 AM
What about in Python, there seem to be competing modules to decode a url (Werkzeug...)... You use Python a lot, right, do you have a favorite?
`if (!defined $q->param('mode')) {`
that's easier on the eyes for me... but would Perl people like youprefer the first one you wrote?
 
Its user preference, in python I would probably use:
def foo(**kwargs):
if 'param' in kwargs:
param = kwargs['param']
else:
...
 
a dictionary catchall parameter
 
Im not sure what it is for query's, I do most of my web functional programing in Perl
 
I'd like to get deeper into Python over the coming months, as opposed to just messing around with code scraps. :)
functional programming, are you talking about functional as in Haskell, or as solid code that does stuff?
 
solid code
 
2:51 AM
i bet it's solid :)
rock solid
no backdoors for hacker friends?
:)
 
Not if you write in SSL certs
 
I want to tell you more about that piece of c++ code I found.
Over lunch I was thinking that instead of trying to compile it in windows, I might try to compile it on linux, and throw a web interface on top, so it's easily accessible in the browser...
Like the code you're working on.
I have to hunt around for the url
It's a pretty cool regex function in my view
 
Ok, we can see what we can do
 
If I get it to work I'll throw it on a website.
It's not as useful as what you're trying to do.
What it does is that it takes a regex like `cat|catalog` and gives you an optimized version like `cat(?:alog)?`, things like that
 
3:33 AM
Ill take a look
What about this so far? liveforfaith.com/re/explain.pl
 
3:48 AM
Yes, brilliant. :)
On the other script, on second thought, it's probably a bad idea to put it on a public-facing website: too easy to enter a crazy string that takes too much cpu to optimize and blow up the web server...
The checkbox works well, nice to switch between the modes!
 
Yea whatever other feedback or options you think just let me know
 
4:29 AM
Okay, will do as I start using it. Thanks! :)
 
 
8 hours later…
12:06 PM
@hwnd Remember that c++ alternation optimizer I was curious about?
Apparently there's a module with even more optimization tricks, already built into your language, Perl!
https://metacpan.org/pod/Regexp::Assemble
Had you heard of it?
In the world of regex Perl seems to be in a league of its own, ey? At least that's what comes through from reading the history of the language, I know close to nothing about the syntax.

Still think that a world-facing interface is not a hot idea as some jokers will try to blow up your server, but it's a cool trick to have up your sleeve. :)
 

  last day (61 days later) »