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

Is there a list of regex patterns for common usecases like imei/geo cordinates etc. somewhere . My google searches are leading me either to regex tutorial sites or regex libraries. There are handful of results for emails/url etc. but not getting exhaustive list.


Do geographical coordinates have a standard layout? I'd expect that you have to look at your particular data for cases like this.

Something like IMEI should be pretty easy, if Wikipedia [0] is to be trusted (e.g. in Python):

    # Matches IMEI and IMEISV
    imei_pattern = re.compile(r"\d{2}-\d{6}-\d{6}-\d\d?")
You could write a big monster pattern that sets up capture groups for all the different TAC and Check Digit variants, but why bother? Just slice off what you need from the result after matching.

0: https://en.wikipedia.org/wiki/International_Mobile_Equipment...




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

Search: