Live data from Hacker News

RegEx101.com now offers a debugger

regex101.com

11–20 of 35 posts

Re: RegEx101.com now offers a debugger

#12
What is it with the obsession with regular expressions? They are useful things, sure, but I just use them in connection with grep or if I search for strings and normally they are pretty basic, e.g.

$ grep -r -n --color "foo*bar" src

If I want to validate input data with the machine I just use a parser.

Re: RegEx101.com now offers a debugger

#14
post #4
post #2

Would be ultra-cool if you could propose a "generate a matching sample" button.

I have thought about this, but in cases where it would be useful, it's impossible to generate a sample match string. For example, creating a match string for /(?:a|[bc])efg?/ is super simple, but for something like: /(ab(?1)*)/ it becomes much harder. Not to mention the performance hit you would see for these more complex expressions. (These are just dummy expressions for illustrative purposes, but I'm sure you get m…

If there is a modifier with a variable number like ?,+,* you could just repeat it X times.

For example if it is ? repeat 1 time, + repeat 2, * repeat 3 etc...

If it is |, choose the first or choose randomly.

Re: RegEx101.com now offers a debugger

#16
post #15

Not bad. You don't have to jump around your regexp reference and editor. It does not exactly tell you why your exp & string does not match. It just show what typed reg exp will do.

I think this shows quite clearly what is going on and why I get the result I get: http://regex101.com/r/kU3cJ6/#debugger (imgur link: http://imgur.com/H2IkNGy)

If you don't agree with me, could you perhaps suggest an improvement?

Re: RegEx101.com now offers a debugger

#17

What is it with the obsession with regular expressions? They are useful things, sure, but I just use them in connection with grep or if I search for strings and normally they are pretty basic, e.g. $ grep -r -n --color "foo*bar" src If I want to validate input data with the machine I just use a parser.

[deleted]

Re: RegEx101.com now offers a debugger

#18
post #15

Not bad. You don't have to jump around your regexp reference and editor. It does not exactly tell you why your exp & string does not match. It just show what typed reg exp will do.

I think this shows quite clearly what is going on and why I get the result I get: http://regex101.com/r/kU3cJ6/#debugger (imgur link: http://imgur.com/H2IkNGy ) If you don't agree with me, could you perhaps suggest an improvement?

I mean it does its job and it is good. I would use it. But look at this case; test string inout [123:0] Asdfg

Exp (made it wrong in purpose) ^inout\s+\[[0-9]\: It just display "No Matches".

It would be cool if it kind of guide what exp you want to use to match test string. What you put in Test string is what you want to get.

Re: RegEx101.com now offers a debugger

#19

What is it with the obsession with regular expressions? They are useful things, sure, but I just use them in connection with grep or if I search for strings and normally they are pretty basic, e.g. $ grep -r -n --color "foo*bar" src If I want to validate input data with the machine I just use a parser.

I don't think your example does what you think it does, match fo followed by o zero or more times, followed by bar.

when you do understand regex, you'll be amazed at the myriad of things you can do with it.

Re: RegEx101.com now offers a debugger

#20

What is it with the obsession with regular expressions? They are useful things, sure, but I just use them in connection with grep or if I search for strings and normally they are pretty basic, e.g. $ grep -r -n --color "foo*bar" src If I want to validate input data with the machine I just use a parser.

Regexes are an elegant and very powerful way to validate data in scripts in a concise (and if they aren't abused) easy to read fashion. There are almost infinite number of examples, but let's say I want to verify that a field is a 64 Bit hexadecimal MAC address

   $mac =~ ^[A-Fa-f0-9]{16}$
Gets the job done. How else, but a regular expression so concisely?

And, when you say, "If I want to validate input data with the machine I just use a parser." - that's pretty much what a regex engine is - a sophisticated parser, and the regular expression is the "commands" that you feed to it to parse the input text.

Post reply on HN