2 ms·
it's always difficult to comment on these kinds of posts because, obviously, they're pretty general, and the person doing the interview would need to use their
by andrewcooke 17y ago
it's always difficult to comment on these kinds of posts because, obviously, they're pretty general, and the person doing the interview would need to use their own discretion, etc.
but having said that, one of the example questions seemed a bit odd to me. the idea was to find out whether a candidate knows how to use grep or similar. and the first case is fair enough - phone numbers with a given pattern. but a later example was reformatting code so that parentheses had spaces around them.
now anyone that tries reformatting code with a regular expression deserves everything they get. almost no programming languages have regular grammars, and even if they do, they are probably fiendishly complex (think of comments and strings). to make things worse, if you get something wrong you end up running the risks of introducing some kind of obscure bug in your code...
as i said, maybe i am being too picky. but that was the one example that jumped out as a red flag for the author's experience (which is odd, as i recognise the name, even though i don't really follow personalities on the web much).
edit: thinking some more, maybe i am being too picky. just last night i used sed to change some import statements in python code. but messing around with parens sounds like playing with fire to me. i vaguely remember, years ago, trying to enforce encoding standards with a regexp based rewriter for some obscure language that had no easily available parser. the memory is a blur, except for the pain...
- silentbicycle 17y agoIt's a good sign if the interviewee thinks about an RE modifying the strings in a program, though. While programmers who think RE are all-powerful are likely outnumbered by those completely ignorant of them, they're out there. It's important to know REs' limitations - sometimes you need an actual parser. (My favorite example: RFC-822-compliant e-mail address validation - http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html)