Published on Tue Mar 01 2022

URL Description from Dr. M. G. @ Brookes

Additional matching regexes for


URL Description from Dr. M. G. @ Brookes

National Insurance Number regular expression

This regular expression is build from the description of NINO number of [GOV.UK](https://www.gov.uk/hmrc-internal-manuals/national-insurance-manual/nim39110),

Text out of all sort of brackets (or in) SUPPORTS: { } [ ] ( ) < >

## I made the description in a CSS file which can be viewed [here](https://drive.google.com/uc?export=view&id=1Dal1yMicNV114JY2u-Y7eC34nlO1y1P_) Dont worry its not a virus or anything\, just inspect the source if you are suspicious \:\)

Match text in square brackets

Drupal7 Media Element in node body - A regex to match the media module square bracketted token/element for embedde images in node body. Use case - using the body text trimmed in a meta description - need to remove the media element as well as strip tags.

How do I write a Regex to inspect Cisco Interfaces

I am asking for help in writing a regular expression to shorten this expression. I need the string below to search every interface within the range of 1 -24 to validate the configuration. If one interface does not have the required configuration then the expression fails. interface GigabitEthernet1/***1 thru 24***.\n(.\n). description ** Unused Port **.\n(.\n). switchport access vlan 333

openweathermap rain and snow

Extract from {"city":{"id":1217734,"name":"Boysun","findname":"BOYSUN","country":"UZ","coord":{"lon":67.198608,"lat":38.206108},"zoom":8,"langs":[{"link":"http:\/\/en.wikipedia.org\/wiki\/Boysun"},{"ru":"Бойсун"}]},"time":1394871628,"main":{"temp":274.74,"temp_min":274.74,"temp_max":274.74,"pressure":823.92,"sea_level":1035.91,"grnd_level":823.92,"humidity":98},"wind":{"speed":0.6,"deg":97.004},"clouds":{"all":92},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"rain":{"3h":0.1},"snow":{"3h":0.85}}

Time duration from minutes to weeks suffixed by letter and whitespace separated

# Brief Description Time duration from minutes to weeks suffixed by corresponding letter and whitespace separated. No unit of time can be omitted. Max values are enforced for minutes, hours, and days, and a max length for weeks. Case is ignored. The string should match completely from start to end. **Exemple:** `3w 2d 10h 15m` # Specs **Time units suffixes** - `w` for weeks - `d` for days - `h` for hours - `m` for minutes **Max values** - `99` for weeks - `6` for days - `23` for hours - `59` for minutes **Min values:** `0` or `00` for all **Separators:** any single whitespace character `\s` **Case is ignored** **Full match RegEx** **Capture Groups** The following capture groups capture the number segments of the respective time unit. - `weeks` - `days` - `hours` - `minutes`

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)_