lorey/social-media-profiles-regexs

Remove "www" and "s" from capture group?

JamoCA opened this issue · 3 comments

I've been developing a library for server-side & client-side link identification & validation. I've been using the non-capturing groups (?:s)? and (?:www\.)?. The regex parser will use it to match the text, but ignores it later when returning the results and can make it easier to identify the account/user/media ID.

Example: ^http(?:s)?:\/\/(?:www\.)?facebook\.com\/([a-zA-Z0-9_]+)$

What is the meaning of using non capturing group for a single character ?
^http(?:s)?
versus
^https?

Sorry. I'm using this same regex in my server-side Java library to isolate and return just the "social media user handle". I didn't need it to also return the protocol "s" or whether "www" is used or not.

lorey commented

Hey @JamoCA, I know it's been years, but I've finally managed to add capturing groups for all expressions. Thanks for the tip back then.