Remove "www" and "s" from capture group?
JamoCA opened this issue · 3 comments
JamoCA commented
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_]+)$
glefait commented
What is the meaning of using non capturing group for a single character ?
^http(?:s)?
versus
^https?
JamoCA commented
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.