Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Extracting Number/Number/Number Patterns from Strings with JavaScript Regex

Автор: vlogommentary

Загружено: 2025-12-23

Просмотров: 0

Описание:

Learn how to efficiently extract number patterns separated by slashes (e.g., '8/8/69') from text using concise JavaScript regular expressions.
---
This video is based on the question https://stackoverflow.com/q/79481727/ asked by the user 'soroosh azadi' ( https://stackoverflow.com/u/21052318/ ) and on the answer https://stackoverflow.com/a/79481743/ provided by the user 'Guillaume Outters' ( https://stackoverflow.com/u/1346819/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Get Number/Number/Number structure in the given string

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.

If anything seems off to you, please feel free to drop me a comment under this video.
---
Problem Overview

You have a string containing text and special sequences formatted as numbers separated by slashes, such as 8/8/69. Your goal is to extract only those sequences that follow a Number/Number/Number pattern, allowing for optional spaces around numbers and slashes.

For example:

[[See Video to Reveal this Text or Code Snippet]]

You want to extract something like:

[[See Video to Reveal this Text or Code Snippet]]

Note that the numbers and slashes might be spaced irregularly, such as ' 8/ 8 / 69 ' or compacted like '8/8/69'.

Solution Using JavaScript Regex

Regular expressions provide an elegant way to match this pattern directly rather than splitting and validating manually.

The Regex Pattern

[[See Video to Reveal this Text or Code Snippet]]

What this means:

[0-9]+ : One or more digits

*: Zero or more spaces

/: A literal slash / (escaped because slashes delimit the regex)

This matches three groups of numbers separated by slashes with optional spaces, for example:

8/8/69

8 / 8 / 69

JavaScript example:

[[See Video to Reveal this Text or Code Snippet]]

The g flag makes sure all matches in the string are returned.

Extending to more numbers

If you want to match sequences like 1/2/3/4 or a flexible number of numbers separated by slashes, you can use repetition:

[[See Video to Reveal this Text or Code Snippet]]

This uses:

( */ *[0-9]+ ){n}: exactly n occurrences of "slash + optional spaces + number"

Summary

Use [0-9]+ */ *[0-9]+ */ *[0-9]+ to match three numbers separated by slashes,

The pattern accommodates spaces before/after the slashes,

Use repetition if you want variable numbers of groups,

Leverage JavaScript's String.match() with the g flag to find all occurrences.

This approach is concise, reliable, and easy to adapt to different requirements around the number of groups or spacing.

Extracting Number/Number/Number Patterns from Strings with JavaScript Regex

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Код работает в 100 раз медленнее из-за ложного разделения ресурсов.

Код работает в 100 раз медленнее из-за ложного разделения ресурсов.

Почему простые числа образуют эти спирали? | Теорема Дирихле и пи-аппроксимации

Почему простые числа образуют эти спирали? | Теорема Дирихле и пи-аппроксимации

33   Userdefined functions

33 Userdefined functions

UTF-8, простое объяснение

UTF-8, простое объяснение

Я перестал пользоваться Google Поиском! Почему вам тоже стоит это сделать.

Я перестал пользоваться Google Поиском! Почему вам тоже стоит это сделать.

Удаляем свои фото, выходим из чатов, скрываем фамилию? Как избежать штрафов

Удаляем свои фото, выходим из чатов, скрываем фамилию? Как избежать штрафов

Самый короткий тест на интеллект Задача Массачусетского профессора

Самый короткий тест на интеллект Задача Массачусетского профессора

Программирование на ассемблере без операционной системы

Программирование на ассемблере без операционной системы

Learn Regular Expressions Fast - JavaScript Regex Tutorial for Developers

Learn Regular Expressions Fast - JavaScript Regex Tutorial for Developers

Но почему площадь поверхности сферы в четыре раза больше ее тени?

Но почему площадь поверхности сферы в четыре раза больше ее тени?

Суть линейной алгебры: #14. Собственные векторы и собственные значения [3Blue1Brown]

Суть линейной алгебры: #14. Собственные векторы и собственные значения [3Blue1Brown]

Как производятся микрочипы? 🖥️🛠️ Этапы производства процессоров

Как производятся микрочипы? 🖥️🛠️ Этапы производства процессоров

Как сжимаются изображения? [46 МБ ↘↘ 4,07 МБ] JPEG в деталях

Как сжимаются изображения? [46 МБ ↘↘ 4,07 МБ] JPEG в деталях

ЭКЗАМЕН США ЗА 9 КЛ! Устное решение!

ЭКЗАМЕН США ЗА 9 КЛ! Устное решение!

Твоя ПЕРВАЯ НЕЙРОСЕТЬ на Python с нуля! | За 10 минут :3

Твоя ПЕРВАЯ НЕЙРОСЕТЬ на Python с нуля! | За 10 минут :3

Почему на конденсаторе такая метка? Вот почему!

Почему на конденсаторе такая метка? Вот почему!

Каково это — изобретать математику?

Каково это — изобретать математику?

Обзор типичного ФИШИНГОВОГО сайта

Обзор типичного ФИШИНГОВОГО сайта

А что если найти среднюю длину эллипса?

А что если найти среднюю длину эллипса?

Наемник, воевавший в Украине, осужден за двойное убийство во Флориде

Наемник, воевавший в Украине, осужден за двойное убийство во Флориде

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com