Extract URL parts only named capturing groups

Published on Tue Mar 01 2022

Extract URL parts only named capturing groups

Additional matching regexes for
Extract URL parts only named capturing groups

Extract URL parts only named capturing groups

Extract URL parts only named capturing groups

URL extractor

Extract parts of an URL.

Extract parts of a URL on Python

Extract parts of a URL on Python

SFTP or FTP url

Parse an SFTP or FTP url and brak it into named capture groups.

Rubik Parser

extract face/slice/axis rotations, pieces, patterns and groups

Phone number tests

Test a given string for phone number variations and extract th parts.

JSON validator

Takes a JSON string and captures interesting information in the named capturing groups: (o: last object, a: last array, s: last string, n: last number, c: last comma before optional whitespace, d: same as c, but with a colon instead of a comma, v: last value)

Valid RGB color value

Pattern for matching actually valid RGB values. - validate separator (mixing spaces and commas between values is not valid) - validate if comma is used as separator if alpha channel is set - validate units (mixing percentage with integers is not valid) - extract `r`, `g`, `b`, `a`, `separator` and `unit` with named groups

Duration with mandatory 'm'

Parses date-time duration strings [+-][P]1y2M3d4h5m6s, where 'm' is the dafault. Like this, where {} contains list of capturing groups: 21 - parsed as {,,,,21,} 2y2s - parsed as {2,,,,,2}

Date - Extract & Validate - Fully tested - Format YYYY-MM-DD (dynamic parts separator / can use a different separator)

A fully tested regex that extracts and validates date parts using named capturing groups. \ **Validations:** - Year must be preceded by nothing or a non-digit character - Year must have 4 digits - Month must be between 01 and 12 - Month must have 2 digits - Day must be between 01 and the maximum number of days for the month (e.g. february can't have more than 29 days) - Day must have 2 digits - Day must be followed by nothing or a non-digit character - Separator must be any single character that is not a space or an alphanumeric character - Separator must be the same between each date part \ **Capturing groups:** ```plain | # | Name | Description | |:-:|:-------:|-------------------------------------| | 1 | `year` | 4 digits of the year | | 2 | `sep` | Date parts separator | | 3 | `month` | 2 digits of the month | | 4 | `day` | 2 digits of the date (day of month) | ``` \ **Example usage:** ```js let match = regex.exec('2020-11-22') console.log('year: %s, month: %s, day: %s', match.groups.year, match.groups.month, match.groups.day) // year: 2020, month: 11, day: 22 ``` \ **Compatibility:** _(updated 2020-11-20)_ - Chrome >= 64 - Edge >= 79 - Firefox >= 78 - IE incompatible (lookbehind assertions & named capture groups not supported) - Opera >= 51 - Safari incompatible (lookbehind assertions not supported) - NodeJS >= 10.0.0 See [regex compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Browser_compatibility). \ _**Note:** does not validate leap years (not really possible in regex)_