캡쳐링 그룹(Capturing Group)

const text    = "text example http://dev.rito15.com/route/path?query=value abcde"
const pattern = "https?:\/\/(**\w+**)?\.?(**\w+\.\w+**)\/\S+"
//                  Groups: ^^^^^    ^^^^^^^^^^

/* [결과]
Match 1 : http://dev.rito15.com/route/path?query=value
Group 1 : dev
Group 2 : rito15.com
*/

넌캡쳐링 그룹(Non-capturing Group)

const text    = "text example http://dev.rito15.com/route/path?query=value abcde"
const pattern = "https?:\/\/(?:**\w+**)?\.?(**\w+\.\w+**)\/\S+"
//     Non-Capturing Group: ^^^^^^^

/* [결과]
Match 1 : http://dev.rito15.com/route/path?query=value
Group 1 : rito15.com
*/

네임드 캡쳐링 그룹(Named Capturing Group)

const text    = "text example http://dev.rito15.com/route/path?query=value abcde"
const pattern = "https?:\/\/(\w+)?\.?(?<domain>**\w+\.\w+**)\/\S+"
//            Named Capturing Group: ^^^^^^^^^^^^^^^^^^^

/* [결과]
Match 1      : http://dev.rito15.com/route/path?query=value
Group 1      : dev
Group domain : rito15.com
*/

참고