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

Quite useful in situations such as:

> (str.match(regexWithGroup) || [, null])[1]

I.e. if the regex matches, then give me the first group (1st index) otherwise give me null.



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

Search: