Live data from Hacker News

RegExr 2.0

regexr.com

41–47 of 47 posts

Re: RegExr 2.0

#41
post #7

I'm guessing the following is either near-impossible or pure-impossible, but: Is there a tool that allows you to highlight portions of a string and generate a corresponding regex? (i.e. the inverse of RegExr)

Here is the problem with that: Consider the string abcdefgh Guess what!? I have the perfect regex to match your string. "abcdefgh" So given a string literal, there is always a regex to match that literal. Namely, the literal itself. Really, what you want is a tool that, given several examples, will generate a regex that matches all of them. So you'd give it: aaaaabaa aabaaa aba abaaaaa And it'd generate "a+ba+" The p…

Sounds like you want to be able to specify some kind of pattern to define accepted and rejected matches. A regex would be ideal for this. oh wait....

Re: RegExr 2.0

#42
post #21

Regex testing is cool, but there are dozens of these kinds of tools and I'd really love to see some other kinds of regex tools - A list generator. Enter a regex, set repetition operator constraints (e.g. ->{0,3}, +->{1,3}, .->[A-Z0-9 ], etc.) and have it exhaustively generate a list of matching strings. This is helpful when you have a regex that matches your test strings, but also to let you know what else* it'll mat…

I actually do the combining idea all the time. As long as the language is roughly pcre compatible you can use this to spit out your regex and (if necessary for your alternate language tweak it a bit so it fits).

I've generated some very massive regex's that are quite speedy.

Merger

  https://metacpan.org/pod/Regexp::Assemble
These are also super handy

  https://metacpan.org/pod/Number::Range::Regex
  https://metacpan.org/pod/Regexp::Common

Re: RegExr 2.0

#43
post #42
post #21

Regex testing is cool, but there are dozens of these kinds of tools and I'd really love to see some other kinds of regex tools - A list generator. Enter a regex, set repetition operator constraints (e.g. ->{0,3}, +->{1,3}, .->[A-Z0-9 ], etc.) and have it exhaustively generate a list of matching strings. This is helpful when you have a regex that matches your test strings, but also to let you know what else* it'll mat…

I actually do the combining idea all the time. As long as the language is roughly pcre compatible you can use this to spit out your regex and (if necessary for your alternate language tweak it a bit so it fits). I've generated some very massive regex's that are quite speedy. Merger https://metacpan.org/pod/Regexp::Assemble These are also super handy https://metacpan.org/pod/Number::Range::Regex https://metacpan.org/p…

Yeah, Regexp::Assemble was what I had in mind. There's a few that try to generate a list of matching strings from the expression, but I've never been satisfied with their output. Either they're slow, or don't let you constrain the regex, and all of them don't generate comprehensive lists for some reason.

Re: RegExr 2.0

#44
post #7

I'm guessing the following is either near-impossible or pure-impossible, but: Is there a tool that allows you to highlight portions of a string and generate a corresponding regex? (i.e. the inverse of RegExr)

"aaa" is a valid regex that matches the string "aaa". If you have special characters in your source string, many libraries have a regex for escaping them. So, generating a regex to match your exact string is trivial. Even matching a group of strings is trivial via (aaa|bbb|etc), though it gets long. Given that, what I think you're really asking is, "how do I automatically generate a regex of optimal conciseness given…

this is very cool ty for the post.

Re: RegExr 2.0

#45
post #20

Earlier quoted context omitted.

Just to make it clear: It does not even support the basic Latin-1 charset correctly. Matching my family-name requires manual intervention. This is sad. It seems a very nice regex page otherwise.

Creator here - can you elaborate? What is your family name? The example in this thread ("Grüneis") matches and displays correctly in all the browsers I've tested. Are you perhaps trying to use a RegEx feature that is not supported by JS? Currently, RegExr only supports the JS flavour of RegEx.

[deleted]

Re: RegExr 2.0

#46
post #20

Earlier quoted context omitted.

Just to make it clear: It does not even support the basic Latin-1 charset correctly. Matching my family-name requires manual intervention. This is sad. It seems a very nice regex page otherwise.

Creator here - can you elaborate? What is your family name? The example in this thread ("Grüneis") matches and displays correctly in all the browsers I've tested. Are you perhaps trying to use a RegEx feature that is not supported by JS? Currently, RegExr only supports the JS flavour of RegEx.

Forget it, I was not used to JavaScript RegEx. I just looked it up on MDN, and it really defines `\w` to be very limited. Doesn't really make it any better, but whatever.

Re: RegExr 2.0

#47

Why can I not match against "\w*" for instance? It just says "infinite" and does not seem to attempt to match.

Creator here - this is because \w* matches 0 characters, and thus matches infinitely. You can roll over the "infinite" error for details, or look in the help. Try \w+ instead.

But \w* matches "" and "abc" but not "!a". How can I test this with your tool if \w* always says "infinite"?
Post reply on HN