last day (15 days later) » 

03:20
0
Q: Best way to comment regex

FracturedRetinaRegular expressions are one of the worst aspects of debugging hell. Since they are contained in string literals, It's hard to comment how they work when the expressions are fairly long. Say I have the following regular expression to match phone numbers \b\d{3}[-.]?\d{3}[-.]?\d{4}\b Source: Re...

@rolfl Edited! I was hoping for a cross-language solution.
While the concept of regular expressions exists in many languages, the syntax varies wildly. A cross-language solution would therefore be hypothetical code, which is off-topic for Code Review.
If you could revise the question such that it contains an actual working phone number matcher in a specific language, we may be able to reopen the question.
@200_success Is there a site better suited to this kind of question?
Such a vague question would likely be considered "too broad" on all other Stack Exchange sites. You're welcome to ask a specific question n times for n different languages, though — right here on Code Review. Just make sure that each one contains tested working code that solves a real task. (See help center.)
@200_success Thanks, I've revised the question. Is there anything else I need to do to fix it.
03:20
It still looks hypothetical to me. What language is that, and does that code actually work? Please add a language tag.
@200_success Done.
I get the feeling that you aren't taking our standards seriously. Where is this hypothetical regexMatch() function defined? How could your regex possibly work?
@200_success There, I used the normal constructor, now could you please reopen this question.
I'm still not convinced that you have working code. Could you please provide a complete program, starting with public static void main(String[] args) that demonstrates both a successful and rejected match against the pattern?
04:16
Full program added.
04:39
Sorry, that's not remotely close to even compiling, let alone working.
 
10 hours later…
14:52
The code now properly compiles and does what I intend it to do.
 
1 hour later…
16:00
Sincerest apologies, I now realize what you want; I'll have that up soon.
 
1 hour later…
17:28
@FracturedRetina Thank you very much for revising the question to meet our standards. I hope my answer demonstrates why we want to review concrete examples with real, working code, not cross-language hypothetical questions.

last day (15 days later) »