Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have no idea what you're talking about. My point is more pragmatic the regex /A/ will match the string "QQQQ" and this tool doesn't take that into account. E.g., I type this into my javascript console:

     /A*/.test('QQQQ');
     > true
Showing that yes, /A
/ does match 'QQQQ'


No, it doesn't. It matches the empty string at the beginning of 'QQQQ', not the Qs themselves:

    /A*/.exec('QQQQ')
    [""]
When computer scientists discuss what a regular express does and does not "match", they are saying that strings which are "matched" by a regex are those strings which are members of the regular language defined by the regex. QQQQ is not a string in the language defined by /A* /, so /A* / does not match QQQQ.

If we look at things your way, we would have to say that the regex /A/ matches "AQQQQ". It does not. It matches "A".


Actually this is wrong, when you use A* in vim for example you're not looking exactly for A* but for substring containing an A* since this also matches "" programs like vim will match anything.

Just because these tools use regex this way doesn't mean that's how regex really works.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: