Elysia Tools

Просматривайте инструменты, примеры, визуальные объяснения и тематические руководства в одном понятном пространстве.

Популярные категории

Темы

Язык
ZHESPTRUFRDEEN

Elysia Tools

Навигация

Обработка текста

Примеры Замены Regex

Коллекция общих и полезных шаблонов замены regex для преобразования текста и очистки данных

Примеры

Элементы этой коллекции

ТекстregexСредний

Преобразование Формата Даты

Преобразование между различными форматами даты (ISO в локальный, США в европейский и т.д.)

Сложность

5/10

Оценка времени

10 min

Теги

date, format, conversion, time

regex
# Date Format Conversion Examples
# Common regex patterns for converting between date formats

# --- ISO to US Format (YYYY-MM-DD → MM/DD/YYYY) ---
# Pattern: (\d{4})-(\d{2})-(\d{2})
# Replacement: $2/$3/$1
# Input: 2024-12-25
# Output: 12/25/2024

# --- ISO to European Format (YYYY-MM-DD → DD.MM.YYYY) ---
# Pattern: (\d{4})-(\d{2})-(\d{2})
# Replacement: $3.$2.$1
# Input: 2024-12-25
# Output: 25.12.2024

# --- US to ISO Format (MM/DD/YYYY → YYYY-MM-DD) ---
# Pattern: (\d{2})/(\d{2})/(\d{4})
# Replacement: $3-$1-$2
# Input: 12/25/2024
# Output: 2024-12-25

# --- European to ISO Format (DD.MM.YYYY → YYYY-MM-DD) ---
# Pattern: (\d{2})\.(\d{2})\.(\d{4})
# Replacement: $3-$2-$1
# Input: 25.12.2024
# Output: 2024-12-25

# --- Text Month to Number (December 25, 2024 → 12/25/2024) ---
# Pattern: (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{1,2}), (\d{4})
# Replacement (needs mapping): Use with callback function for month mapping

# --- Add Time to Date (2024-12-25 → 2024-12-25 00:00:00) ---
# Pattern: ^(\d{4}-\d{2}-\d{2})$
# Replacement: $1 00:00:00
# Input: 2024-12-25
# Output: 2024-12-25 00:00:00

# --- Remove Time from Date (2024-12-25 14:30:00 → 2024-12-25) ---
# Pattern: ^(\d{4}-\d{2}-\d{2}).*$
# Replacement: $1
# Input: 2024-12-25 14:30:00
# Output: 2024-12-25

# --- Convert Month Name to Abbreviation (December → Dec) ---
# Pattern: \b(January|February|March|April|May|June|July|August|September|October|November|December)\b
# Replacement (varies by month): Use with lookup table

# --- Ordinal Dates (December 25th → December 25) ---
# Pattern: (\d{1,2})(st|nd|rd|th)
# Replacement: $1
# Input: December 25th, 2024
# Output: December 25, 2024
ТекстregexПростой

Форматирование Номера Телефона

Добавление или удаление форматирования номера телефона (тире, скобки, пробелы)

Сложность

3/10

Оценка времени

8 min

Теги

phone, format, number, contact

regex
# Phone Number Formatting Examples
# Patterns for standardizing phone number formats

# --- Add Dashes (1234567890 → 123-456-7890) ---
# Pattern: (\d{3})(\d{3})(\d{4})
# Replacement: $1-$2-$3
# Input: 1234567890
# Output: 123-456-7890

# --- Add Parentheses and Dash (1234567890 → (123) 456-7890) ---
# Pattern: (\d{3})(\d{3})(\d{4})
# Replacement: ($1) $2-$3
# Input: 1234567890
# Output: (123) 456-7890

# --- Remove All Formatting (123-456-7890 → 1234567890) ---
# Pattern: \D
# Replacement: (empty)
# Input: (123) 456-7890
# Output: 1234567890

# --- Add Spaces (1234567890 → 123 456 7890) ---
# Pattern: (\d{3})(\d{3})(\d{4})
# Replacement: $1 $2 $3
# Input: 1234567890
# Output: 123 456 7890

# --- International Format (+11234567890 → +1 123-456-7890) ---
# Pattern: (\+\d{1})(\d{3})(\d{3})(\d{4})
# Replacement: $1 $2-$3-$4
# Input: +11234567890
# Output: +1 123-456-7890

# --- Convert to International (1234567890 → +1-123-456-7890) ---
# Pattern: ^(\d{3})(\d{3})(\d{4})$
# Replacement: +1-$1-$2-$3
# Input: 1234567890
# Output: +1-123-456-7890

# --- Add Extension Support (1234567890 ext 123 → 123-456-7890 x123) ---
# Pattern: (\d{3})(\d{3})(\d{4})(?: ext\.? (\d+))?
# Replacement: $1-$2-$3 x$4
# Input: 1234567890 ext 123
# Output: 123-456-7890 x123

# --- Normalize Separator (123.456.7890 → 123-456-7890) ---
# Pattern: (\d{3})[.\s](\d{3})[.\s](\d{4})
# Replacement: $1-$2-$3
# Input: 123.456.7890
# Output: 123-456-7890

# --- Format with Country Code (11234567890 → +1 (123) 456-7890) ---
# Pattern: (\d{1})(\d{3})(\d{3})(\d{4})
# Replacement: +$1 ($2) $3-$4
# Input: 11234567890
# Output: +1 (123) 456-7890
ТекстregexСредний

Преобразование Регистра Текста

Изменение регистра совпадающего текста с использованием шаблонов замены

Сложность

6/10

Оценка времени

12 min

Теги

case, casing, uppercase, lowercase, text

regex
# Text Casing Examples
# Note: JavaScript regex replace() doesn\'t support case changes in replacement string
# These patterns show what needs to be matched, with notes on implementation

# --- Uppercase First Letter of Each Word ---
# Pattern: \b\w
# Notes: Use callback function: match => match.toUpperCase()
# Input: hello world
# Output: Hello World

# --- Lowercase All Letters ---
# Pattern: .*
# Notes: Better to use .toLowerCase() directly on the string
# Input: HELLO WORLD
# Output: hello world

# --- Uppercase All Letters ---
# Pattern: .*
# Notes: Better to use .toUpperCase() directly on the string
# Input: hello world
# Output: HELLO WORLD

# --- Title Case After Special Characters ---
# Pattern: (?:^|\s|-|\.)\w
# Notes: Use callback function for each match
# Input: hello-world test.example
# Output: Hello-World Test.Example

# --- Lowercase After Period ---
# Pattern: \.\s*(\w)
# Notes: Use callback to lowercase the letter
# Input: Hello. WORLD.
# Output: Hello. World.

# --- Capitalize Sentences ---
# Pattern: (?:^|[.!?]\s+)([a-z])
# Notes: Use callback to capitalize first letter after sentence endings
# Input: hello. world. test.
# Output: Hello. World. Test.

# --- SCREAMING_SNAKE_CASE to camelCase ---
# Pattern: (_)([A-Z])
# Notes: Use callback: match => match[1].toUpperCase()
# Input: SCREAMING_SNAKE_CASE
# Output: screamingSnakeCase

# --- kebab-case to camelCase ---
# Pattern: (-)([a-z])
# Notes: Use callback: match => match.toUpperCase()
# Input: kebab-case-string
# Output: kebabCaseString

# --- camelCase to snake_case ---
# Pattern: ([a-z])([A-Z])
# Replacement: $1_$2
# Then lowercase the result
# Input: camelCaseString
# Output: camel_case_string

# --- PascalCase to snake_case ---
# Pattern: ([A-Z])
# Replacement: _$1 (then trim leading _ and lowercase)
# Input: PascalCaseString
# Output: pascal_case_string

# --- Remove Extra Capitals (hELLO → HELLO) ---
# Pattern: ([A-Z])([a-z])
# Notes: Complex - use callback logic
# Input: hELLO wORLD
# Output: HELLO WORLD
ТекстregexСредний

Нормализация URL

Стандартизация URL-адресов путем добавления протокола, удаления www, нормализации путей

Сложность

5/10

Оценка времени

10 min

Теги

url, web, link, normalization

regex
# URL Normalization Examples
# Patterns for standardizing URL formats

# --- Add HTTPS Protocol (example.com → https://example.com) ---
# Pattern: ^(?!https?://)(.*)
# Replacement: https://$1
# Input: example.com
# Output: https://example.com

# --- Remove www (https://www.example.com → https://example.com) ---
# Pattern: https?://www\.(.*)
# Replacement: https://$1
# Input: https://www.example.com
# Output: https://example.com

# --- Add Trailing Slash (https://example.com → https://example.com/) ---
# Pattern: ^(https?://[^/]+)$
# Replacement: $1/
# Input: https://example.com
# Output: https://example.com/

# --- Remove Trailing Slash (https://example.com/ → https://example.com) ---
# Pattern:^(https?://.+)/$
# Replacement: $1
# Input: https://example.com/
# Output: https://example.com

# --- Convert HTTP to HTTPS (http://example.com → https://example.com) ---
# Pattern: http://(.*)
# Replacement: https://$1
# Input: http://example.com
# Output: https://example.com

# --- Remove Duplicate Slashes (https://example.com//path → https://example.com/path) ---
# Pattern: (?<!:)/{2,}
# Replacement: /
# Input: https://example.com//path
# Output: https://example.com/path

# --- Normalize Path Slashes (https://example.com/path/ → https://example.com/path) ---
# Pattern: (.+)/$
# Replacement: $1
# Input: https://example.com/path/
# Output: https://example.com/path

# --- Remove Fragment (https://example.com#section → https://example.com) ---
# Pattern: ^(.*?)#.*$
# Replacement: $1
# Input: https://example.com#section
# Output: https://example.com

# --- Remove Query Parameters (https://example.com?param=value → https://example.com) ---
# Pattern: ^(.*?)\?.*$
# Replacement: $1
# Input: https://example.com?param=value
# Output: https://example.com

# --- Remove Port Number (https://example.com:8080 → https://example.com) ---
# Pattern: ^(https?://[^/:]+):\d+(.*)$
# Replacement: $1$2
# Input: https://example.com:8080/path
# Output: https://example.com/path

# --- Lowercase Domain (HTTPS://EXAMPLE.COM → https://example.com) ---
# Pattern: ^(https?://)([^/]+)
# Notes: Use callback to lowercase group 2
# Input: HTTPS://EXAMPLE.COM
# Output: https://example.com
ТекстregexПростой

Обфускация Электронной Почты

Скрытие или маскирование адресов электронной почты с помощью звездочек или заполнителей

Сложность

4/10

Оценка времени

8 min

Теги

email, privacy, obfuscation, masking

regex
# Email Obfuscation Examples
# Patterns for hiding or masking email addresses

# --- Mask All But First Letter ([email protected] → j***@example.com) ---
# Pattern: (\w)(\w+@(\w+\.)*\w+)
# Notes: Use callback to replace group 2 with asterisks
# Input: [email protected]
# Output: j***@example.com

# --- Mask Domain ([email protected] → john@******.com) ---
# Pattern: @(\w+\.)(\w+)
# Notes: Use callback to mask domain name
# Input: [email protected]
# Output: john@******.com

# --- Show First and Last ([email protected] → j***[email protected]) ---
# Pattern: (\w)(\w+)(\w)@
# Notes: Use callback to replace middle with asterisks
# Input: [email protected]
# Output: j***[email protected]

# --- Full Mask ([email protected] → ****@*****.com) ---
# Pattern: (\w+)@(\w+\.?)+\w+
# Notes: Replace each group with asterisks of same length
# Input: [email protected]
# Output: ****@*****.com

# --- Replace with Placeholder ([email protected] → [email hidden]) ---
# Pattern: \b[\w.%+-]+@[\w.-]+\.[A-Z]{2,}\b
# Replacement: [email hidden]
# Input: Contact [email protected]
# Output: Contact [email hidden]

# --- Show Domain Only ([email protected] → ***@example.com) ---
# Pattern: \w+(@[\w.-]+\.[A-Z]{2,})
# Replacement: *$1
# Input: [email protected]
# Output: *@example.com

# --- Mask TLD ([email protected] → john@example.***) ---
# Pattern: @(\w+\.)(\w+)
# Replacement: @$1***
# Input: [email protected]
# Output: john@example.***

# --- Partial Username ([email protected] → jo***@example.com) ---
# Pattern: (\w{2})(\w+)@
# Notes: Use callback to replace rest with asterisks
# Input: [email protected]
# Output: jo***@example.com

# --- Format for Display ([email protected] → john [at] example [dot] com) ---
# Pattern: ([\w.%+-]+)@([\w.-]+)\.([A-Z]{2,})
# Replacement: $1 [at] $2 [dot] $3
# Input: [email protected]
# Output: john [at] example [dot] com

# --- Add Prefix ([email protected] → Email: [email protected]) ---
# Pattern: ([\w.%+-]+@[\w.-]+\.[A-Z]{2,})
# Replacement: Email: $1
# Input: [email protected]
# Output: Email: [email protected]
ТекстregexСредний

Удаление и Преобразование HTML-тегов

Удаление HTML-тегов или преобразование их в markdown и другие форматы

Сложность

6/10

Оценка времени

12 min

Теги

html, markdown, conversion, strip

regex
# HTML Tag Removal and Conversion Examples
# Patterns for stripping or converting HTML markup

# --- Remove All HTML Tags ---
# Pattern: <[^>]*>
# Replacement: (empty)
# Input: <p>Hello <b>world</b></p>
# Output: Hello world

# --- Convert <b> to Markdown Bold ---
# Pattern: <b>(.*?)</b>
# Replacement: **$1**
# Input: <b>bold text</b>
# Output: **bold text**

# --- Convert <i> to Markdown Italic ---
# Pattern: <i>(.*?)</i>
# Replacement: *$1*
# Input: <i>italic text</i>
# Output: *italic text*

# --- Convert <h1> to Markdown Header ---
# Pattern: <h1>(.*?)</h1>
# Replacement: # $1
# Input: <h1>Title</h1>
# Output: # Title

# --- Convert <a> to Markdown Link ---
# Pattern: <a href="([^"]*)"[^>]*>(.*?)</a>
# Replacement: [$2]($1)
# Input: <a href="https://example.com">Link</a>
# Output: [Link](https://example.com)

# --- Convert <img> to Markdown Image ---
# Pattern: <img src="([^"]*)"[^>]*alt="([^"]*)"[^>]*/?>
# Replacement: ![$2]($1)
# Input: <img src="pic.jpg" alt="Picture"/>
# Output: ![Picture](pic.jpg)

# --- Remove Script Tags ---
# Pattern: <script[^>]*>.*?</script>
# Replacement: (empty)
# Input: Hello<script>alert('xss')</script>World
# Output: HelloWorld

# --- Remove Style Tags ---
# Pattern: <style[^>]*>.*?</style>
# Replacement: (empty)
# Input: Text<style>body{color:red;}</style>More
# Output: TextMore

# --- Convert <br> to Newline ---
# Pattern: <br\s*/?>|<br>
# Replacement: \n
# Input: Line 1<br>Line 2
# Output: Line 1\nLine 2

# --- Convert <code> to Backticks ---
# Pattern: <code[^>]*>(.*?)</code>
# Replacement: `$1`
# Input: <code>var x = 1;</code>
# Output: `var x = 1;`

# --- Remove HTML Comments ---
# Pattern: <!--.*?-->
# Replacement: (empty)
# Input: Text<!-- comment -->More text
# Output: TextMore text

# --- Convert <ul>/<li> to Markdown List ---
# Pattern: </?ul>|<li>(.*?)</li>
# Replacement (multiple steps): First remove ul tags, then replace li with "  - $1"

# --- Decode HTML Entities (&amp; → &) ---
# Pattern: &amp;
# Replacement: &
# Input: Tom &amp; Jerry
# Output: Tom & Jerry

# --- Decode &lt; and &gt; ---
# Pattern: &lt;|&gt;
# Replacement (two steps): &lt; → <, &gt; → >
# Input: &lt;tag&gt;
# Output: <tag>
ТекстregexСредний

Форматирование Чисел

Добавление разделителей тысяч, форматирование десятичных знаков и нормализация чисел

Сложность

5/10

Оценка времени

10 min

Теги

number, format, decimal, separator

regex
# Number Formatting Examples
# Patterns for formatting numbers with separators and decimals

# --- Add Thousand Separators (1000000 → 1,000,000) ---
# Pattern: \B(?=(\d{3})+(?!\d))
# Replacement: ,
# Input: 1000000
# Output: 1,000,000

# --- Remove Thousand Separators (1,000,000 → 1000000) ---
# Pattern: ,
# Replacement: (empty)
# Input: 1,000,000
# Output: 1000000

# --- Add Decimal Point (1000 → 1000.00) ---
# Pattern: ^(\d+)$
# Replacement: $1.00
# Input: 1000
# Output: 1000.00

# --- Format Currency (1000000 → $1,000,000.00) ---
# Pattern: (\d)
# Notes: Multiple step process with callbacks
# Input: 1000000
# Output: $1,000,000.00

# --- Round to 2 Decimals (123.456 → 123.46) ---
# Pattern: ^\d+\.\d{2}(\d)
# Notes: Use callback for rounding logic
# Input: 123.456
# Output: 123.46

# --- Remove Decimals (123.45 → 123) ---
# Pattern: \.(\d+)
# Replacement: (empty)
# Input: 123.45
# Output: 123

# --- Pad Integer with Zeros (123 → 00123) ---
# Pattern: ^(\d+)$
# Notes: Use callback with padStart(5, '0')
# Input: 123
# Output: 00123

# --- Format Percentage (0.85 → 85%) ---
# Pattern: (\d+)\.\d+
# Notes: Use callback to multiply by 100
# Input: 0.85
# Output: 85%

# --- Add Plus Sign for Positive (+100) ---
# Pattern: ^(\d+)$
# Replacement: +$1
# Input: 100
# Output: +100

# --- Format Negative Numbers (-1000 → -1,000) ---
# Pattern: -(\d)(?=(\d{3})+(?!\d))
# Replacement: -$1,
# Input: -1000000
# Output: -1,000,000

# --- Format Phone-like Numbers (1234567 → 123-4567) ---
# Pattern: (\d{3})(\d{4})
# Replacement: $1-$2
# Input: 1234567
# Output: 123-4567

# --- Format SSN (123456789 → 123-45-6789) ---
# Pattern: (\d{3})(\d{2})(\d{4})
# Replacement: $1-$2-$3
# Input: 123456789
# Output: 123-45-6789

# --- Format IP Address (19216811 → 192.168.1.1) ---
# Pattern: (\d{1,3})(\d{1,3})(\d{1,3})(\d{1,3})
# Notes: Requires validation of octet ranges
# Input: 19216811
# Output: 192.168.1.1
ТекстregexПростой

Маскирование Кредитных Карт

Скрытие чувствительных номеров кредитных карт, показ только последних 4 цифр

Сложность

3/10

Оценка времени

6 min

Теги

credit-card, masking, privacy, security

regex
# Credit Card Masking Examples
# Patterns for hiding sensitive credit card numbers

# --- Show Last 4 Digits (1234567890123456 → ****-****-****-3456) ---
# Pattern: \d{12}(\d{4})
# Replacement: ****-****-****-$1
# Input: 1234567890123456
# Output: ****-****-****-3456

# --- Mask All But Last 4 (1234567890123456 • ************3456) ---
# Pattern: \d{12}(\d{4})
# Replacement: ************$1
# Input: 1234567890123456
# Output: ************3456

# --- Mask First 12 with Spaces (1234-5678-9012-3456 • •••• •••• •••• 3456) ---
# Pattern: \d{4}(\d{4})(\d{4})(\d{4})
# Replacement: •••• $1 $2 $3
# Input: 1234567890123456
# Output: •••• 5678 9012 3456

# --- Remove All Digits (1234567890123456 • ••••••••••••••) ---
# Pattern: \d
# Replacement: •
# Input: 1234567890123456
# Output: ••••••••••••••••

# --- Format and Mask (1234567890123456 • **** **** **** 3456) ---
# Pattern: (\d{4})(\d{4})(\d{4})(\d{4})
# Replacement: **** **** **** $4
# Input: 1234567890123456
# Output: **** **** **** 3456

# --- Show Bin and Last 4 (1234567890123456 → 1234******3456) ---
# Pattern: (\d{4})(\d{8})(\d{4})
# Replacement: $1********$3
# Input: 1234567890123456
# Output: 1234********3456

# --- Mask in Sentence (Card: 1234567890123456 • Card: ****3456) ---
# Pattern: \d{12}(\d{4})
# Replacement: ****$1
# Input: Card: 1234567890123456
# Output: Card: ****3456

# --- Add Spaces and Mask (1234567890123456 • •• •• •• 3456) ---
# Pattern: (\d{4})(\d{4})(\d{4})(\d{4})
# Replacement: •• •• •• $4
# Input: 1234567890123456
# Output: •• •• •• 3456

# --- Replace with Placeholder (1234567890123456 • [CARD HIDDEN]) ---
# Pattern: \d{16}
# Replacement: [CARD HIDDEN]
# Input: 1234567890123456
# Output: [CARD HIDDEN]

# --- Mask Groups (1234-5678-9012-3456 • ****-****-****-3456) ---
# Pattern: (\d{4})-(\d{4})-(\d{4})-(\d{4})
# Replacement: ****-****-****-$4
# Input: 1234-5678-9012-3456
# Output: ****-****-****-3456

# --- Partial Mask (1234567890123456 → 1**2**3**4**56) ---
# Pattern: (\d{4})(\d{4})(\d{4})(\d{4})
# Notes: Use callback for custom masking pattern
# Input: 1234567890123456
# Output: 1**2**3**4**56
ТекстregexСредний

Преобразование Markdown

Преобразование markdown в HTML или другие форматы

Сложность

6/10

Оценка времени

12 min

Теги

markdown, html, conversion, format

regex
# Markdown Conversion Examples
# Patterns for converting markdown syntax to other formats

# --- Bold to HTML (**text** → <strong>text</strong>) ---
# Pattern: \*\*(.*?)\*\*
# Replacement: <strong>$1</strong>
# Input: **bold text**
# Output: <strong>bold text</strong>

# --- Italic to HTML (*text* → <em>text</em>) ---
# Pattern: \*(.*?)\*
# Replacement: <em>$1</em>
# Input: *italic text*
# Output: <em>italic text</em>

# --- Headers to HTML (# Title → <h1>Title</h1>) ---
# Pattern: ^(#{1,6})\s+(.*)$
# Replacement (varies by # count): <h{count}>$2</h{count}>
# Input: # Title
# Output: <h1>Title</h1>

# --- Code Block to HTML (```code``` → <pre><code>code</code></pre>) ---
# Pattern: ```([\s\S]*?)```
# Replacement: <pre><code>$1</code></pre>
# Input: ```code here```
# Output: <pre><code>code here</code></pre>

# --- Inline Code to HTML (`code` → <code>code</code>) ---
# Pattern: `([^`]+)`
# Replacement: <code>$1</code>
# Input: `var x = 1;`
# Output: <code>var x = 1;</code>

# --- Links to HTML ([text](url) → <a href="url">text</a>) ---
# Pattern: \[([^\]]+)\]\(([^)]+)\)
# Replacement: <a href="$2">$1</a>
# Input: [Link](https://example.com)
# Output: <a href="https://example.com">Link</a>

# --- Images to HTML (![alt](url) → <img src="url" alt="alt"/>) ---
# Pattern: !\[([^\]]+)\]\(([^)]+)\)
# Replacement: <img src="$2" alt="$1"/>
# Input: ![Picture](pic.jpg)
# Output: <img src="pic.jpg" alt="Picture"/>

# --- Unordered Lists to HTML (- item → <li>item</li>) ---
# Pattern: ^-\s+(.*)$
# Replacement: <li>$1</li>
# Input: - item
# Output: <li>item</li>

# --- Ordered Lists to HTML (1. item → <li>item</li>) ---
# Pattern: ^\d+\.\s+(.*)$
# Replacement: <li>$1</li>
# Input: 1. item
# Output: <li>item</li>

# --- Blockquotes to HTML (> quote → <blockquote>quote</blockquote>) ---
# Pattern: ^>\s+(.*)$
# Replacement: <blockquote>$1</blockquote>
# Input: > Quote text
# Output: <blockquote>Quote text</blockquote>

# --- Horizontal Rule to HTML (--- → <hr/>) ---
# Pattern: ^-{3,}$
# Replacement: <hr/>
# Input: ---
# Output: <hr/>

# --- Strikethrough to HTML (~~text~~ → <del>text</del>) ---
# Pattern: ~~(.*?)~~
# Replacement: <del>$1</del>
# Input: ~~deleted~~
# Output: <del>deleted</del>

# --- Line Breaks to HTML (line\nline → line<br/>line) ---
# Pattern: \n
# Replacement: <br/>
# Input: Line 1\nLine 2
# Output: Line 1<br/>Line 2
ТекстregexПростой

Очистка Строк

Удаление лишних пробелов, разрывов строк и специальных символов

Сложность

3/10

Оценка времени

8 min

Теги

cleanup, spaces, sanitization, cleaning

regex
# String Cleanup Examples
# Patterns for removing extra spaces, line breaks, and special characters

# --- Remove Extra Spaces (hello    world → hello world) ---
# Pattern: \s{2,}
# Replacement: ' '
# Input: hello    world
# Output: hello world

# --- Trim Leading Spaces (   hello → hello) ---
# Pattern: ^\s+
# Replacement: (empty)
# Input:    hello
# Output: hello

# --- Trim Trailing Spaces (hello   → hello) ---
# Pattern: \s+$
# Replacement: (empty)
# Input: hello
# Output: hello

# --- Remove All Spaces (hello world → helloworld) ---
# Pattern: \s
# Replacement: (empty)
# Input: hello world
# Output: helloworld

# --- Remove Line Breaks (line1\nline2 → line1line2) ---
# Pattern: [\r\n]+
# Replacement: (empty)
# Input: line1\nline2
# Output: line1line2

# --- Normalize Line Breaks (\r\n → \n) ---
# Pattern: \r\n
# Replacement: \n
# Input: line1\r\nline2
# Output: line1\nline2

# --- Remove Tab Characters ---
# Pattern: \t
# Replacement: ' '
# Input: hello\tworld
# Output: hello world

# --- Remove Non-ASCII Characters ---
# Pattern: [^\x00-\x7F]
# Replacement: (empty)
# Input: café
# Output: caf

# --- Remove Special Characters (hello@world! → helloworld) ---
# Pattern: [^a-zA-Z0-9\s]
# Replacement: (empty)
# Input: hello@world!
# Output: helloworld

# --- Remove Numbers (abc123 → abc) ---
# Pattern: \d
# Replacement: (empty)
# Input: abc123
# Output: abc

# --- Remove Letters (abc123 → 123) ---
# Pattern: [a-zA-Z]
# Replacement: (empty)
# Input: abc123
# Output: 123

# --- Remove Punctuation (Hello, world! → Hello world) ---
# Pattern: [^a-zA-Z0-9\s]
# Replacement: (empty)
# Input: Hello, world!
# Output: Hello world

# --- Remove Duplicate Lines ---
# Pattern: ^(.*?)$\n?\1$
# Replacement: $1
# Input: line1\nline1\nline2
# Output: line1\nline2

# --- Remove Empty Lines ---
# Pattern: ^\s*$
# Replacement: (empty)
# Input: line1\n\nline2
# Output: line1\nline2

# --- Collapse Multiple Lines to One (line1\nline2 → line1 line2) ---
# Pattern: \n
# Replacement: ' '
# Input: line1\nline2
# Output: line1 line2
ТекстregexСредний

Нормализация Кавычек

Преобразование между прямыми кавычками, фигурными кавычками и другими типами кавычек

Сложность

5/10

Оценка времени

10 min

Теги

quotes, normalization, typography

regex
# Quote Normalization Examples
# Patterns for converting between different quote types

# --- Curly to Straight ("text" → "text") ---
# Pattern: ["|"|'|"|']
# Replacement: " or '
# Input: "Hello" and 'world'
# Output: "Hello" and 'world'

# --- Straight to Curly Double ("text" → "text") ---
# Pattern: "(.*?)"
# Notes: Requires context-aware replacement
# Input: "text"
# Output: "text"

# --- Straight to Curly Single ('text' → 'text') ---
# Pattern: '(.*?)'
# Notes: Requires context-aware replacement
# Input: 'text'
# Output: 'text'

# --- Normalize Double Quotes (""text"" → "text") ---
# Pattern: "{2,}
# Replacement: "
# Input: ""hello""
# Output: "hello"

# --- Normalize Single Quotes (''text'' → 'text') ---
# Pattern: '{2,}
# Replacement: '
# Input: ''hello''
# Output: 'hello'

# --- Convert Smart Quotes Left ("text" → "text") ---
# Pattern: "
# Replacement: "
# Input: "Hello"
# Output: "Hello"

# --- Convert Smart Quotes Right ("text" → "text") ---
# Pattern: "
# Replacement: "
# Input: "Hello"
# Output: "Hello"

# --- Convert Smart Single Left ('text' → 'text') ---
# Pattern: '
# Replacement: '
# Input: 'Hello'
# Output: 'Hello'

# --- Convert Smart Single Right ('text' → 'text') ---
# Pattern: '
# Replacement: '
# Input: 'Hello'
# Output: 'Hello'

# --- Remove Quotes Entirely ("text" → text) ---
# Pattern: ["']
# Replacement: (empty)
# Input: "text" and 'more'
# Output: text and more

# --- Escape Quotes for JSON ("text" → "text") ---
# Pattern: "
# Replacement: \"
# Input: He said "hello"
# Output: He said \"hello\"

# --- Unescape Quotes (\"text\" → "text") ---
# Pattern: \\"
# Replacement: "
# Input: \"hello\"
# Output: "hello"

# --- Convert Backticks to Quotes (`text` → "text") ---
# Pattern: `(.*?)`
# Replacement: "$1"
# Input: `text`
# Output: "text"

# --- Standardize Quote Spacing ( text " → text") ---
# Pattern: \s+(["'])
# Replacement: $1
# Input: hello " world "
# Output: hello "world "
ТекстregexСредний

Преобразование Путей

Преобразование между путями к файлам Windows и Unix, нормализация разделителей

Сложность

5/10

Оценка времени

10 min

Теги

path, filesystem, windows, unix

regex
# Path Conversion Examples
# Patterns for converting between different file path formats

# --- Windows to Unix (C:\\path\\to\\file → /c/path/to/file) ---
# Pattern: ^([A-Z]):\\(.*)$
# Replacement: /$1/$2
# Input: C:\\Users\\name\\file.txt
# Output: /C/Users/name/file.txt

# --- Unix to Windows (/home/user → C:\\home\\user) ---
# Pattern: ^/(.*)$
# Replacement: C:\\$1
# Input: /home/user/file.txt
# Output: C:\home\user\file.txt

# --- Normalize Forward Slashes (path\\to\\file → path/to/file) ---
# Pattern: \\\\
# Replacement: /
# Input: path\\to\\file
# Output: path/to/file

# --- Normalize Back Slashes (path/to/file → path\\to\\file) ---
# Pattern: /
# Replacement: \\\\
# Input: path/to/file
# Output: path\\to\\file

# --- Remove Drive Letter (C:\\path → /path) ---
# Pattern: ^[A-Z]:\\
# Replacement: /
# Input: C:\\Users\\name
# Output: /Users/name

# --- Add Drive Letter (/path → C:\\path) ---
# Pattern: ^/(.*)$
# Replacement: C:\\$1
# Input: /Users/name
# Output: C:\Users\name

# --- Convert Mixed Separators (path/to\\file → path/to/file) ---
# Pattern: [\/]+
# Replacement: /
# Input: path/to\\file
# Output: path/to/file

# --- Remove Trailing Separator (path/to/ → path/to) ---
# Pattern: [\/]+$
# Replacement: (empty)
# Input: path/to/
# Output: path/to

# --- Add Trailing Separator (path/to → path/to/) ---
# Pattern:([^\/]+)$
# Replacement: $1/
# Input: path/to
# Output: path/to/

# --- Remove Duplicate Separators (path//to///file → path/to/file) ---
# Pattern: [\/]{2,}
# Replacement: /
# Input: path//to///file
# Output: path/to/file

# --- UNC to Local Path (\\\\server\\share → //server/share) ---
# Pattern: ^\\\\
# Replacement: //
# Input: \\\\server\\share
# Output: //server/share

# --- Convert Network Path (//server/share → \\\\server\\share) ---
# Pattern: ^
# Replacement: \\\\ (on //server/share patterns)
# Input: //server/share
# Output: \\\\server\\share

# --- Remove Parent References (path/to/../file → path/file) ---
# Pattern: [^/\\]+/\\.\./
# Replacement: (empty)
# Input: path/to/../file
# Output: path/file

# --- Remove Current References (path/./file → path/file) ---
# Pattern: /\\.\./
# Replacement: /
# Input: path/./file
# Output: path/file
ТекстregexСложный

Сложные Преобразования Текста

Сложные преобразования, включая разбор CSV, форматирование журналов и извлечение данных

Сложность

8/10

Оценка времени

15 min

Теги

advanced, transformation, parsing, data

regex
# Advanced Text Transformation Examples
# Complex patterns for data parsing and transformation

# --- CSV to Pipe Delimited (a,b,c → a|b|c) ---
# Pattern: ,
# Replacement: |
# Input: name,age,city
# Output: name|age|city

# --- Pipe to CSV (a|b|c → a,b,c) ---
# Pattern: \|
# Replacement: ,
# Input: name|age|city
# Output: name,age,city

# --- Extract IPs from Log (Failed IP: 192.168.1.1 → 192.168.1.1) ---
# Pattern: \b(?:\d{1,3}\.){3}\d{1,3}\b
# Notes: Use with match() instead of replace
# Input: User at 192.168.1.1 failed
# Output: 192.168.1.1

# --- Extract URLs from Text ---
# Pattern: https?://[^\s]+
# Notes: Use with match() instead of replace
# Input: Visit https://example.com for more
# Output: https://example.com

# --- Extract Email Addresses ---
# Pattern: \b[\w.%+-]+@[\w.-]+\.[A-Z]{2,}\b
# Notes: Use with match() instead of replace
# Input: Contact [email protected]
# Output: [email protected]

# --- Format Log Timestamp (2024-12-25T14:30:00 → 12/25/2024 2:30 PM) ---
# Pattern: (\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})
# Notes: Use callback for complex date formatting
# Input: 2024-12-25T14:30:00
# Output: 12/25/2024 2:30 PM

# --- Remove ANSI Color Codes ---
# Pattern: \x1b\[[0-9;]*m
# Replacement: (empty)
# Input: \x1b[31mError\x1b[0m
# Output: Error

# --- Extract JSON Keys ---
# Pattern: "([^"]+)":
# Notes: Use with match() for key extraction
# Input: {"name": "John", "age": 30}
# Output: name, age

# --- Base64 Encode Preparation ---
# Pattern: (.)
# Notes: Each char needs btoa() conversion
# Input: Hello
# Output: SGVsbG8=

# --- Reverse String (Hello → olleH) ---
# Pattern: .
# Notes: Split, reverse, join - not pure regex

# --- Remove XML Tags ---
# Pattern: <[^>]+>
# Replacement: (empty)
# Input: <tag>content</tag>
# Output: content

# --- Extract Hashtags (Check #trending → #trending) ---
# Pattern: #[\w]+
# Notes: Use with match() instead of replace
# Input: Check #trending topics
# Output: #trending

# --- Extract Mentions (@user → @user) ---
# Pattern: @[\w]+
# Notes: Use with match() instead of replace
# Input: Hey @john check this
# Output: @john

# --- Format JSON (compact → pretty) ---
# Notes: Use JSON.stringify(obj, null, 2)
# Input: {"a":1,"b":2}
# Output: {\n  "a": 1,\n  "b": 2\n}

# --- Minify JSON (pretty → compact) ---
# Notes: Use JSON.stringify(obj)
# Input: {\n  "a": 1\n}
# Output: {"a":1}

Инструменты

Инструменты, которые часто используются с этим примером

Связано

Похожие коллекции примеров

Руководство по использованию инструмента

Контекст для понимания этой коллекции примеров

Заголовок

Примеры Замены Regex

Описание

Коллекция общих и полезных шаблонов замены regex для преобразования текста и очистки данных

Обзор

Коллекция общих и полезных шаблонов замены regex для преобразования текста и очистки данных

Когда использовать

  • Use this sample set when you want reference inputs for Примеры Замены Regex.
  • Use it to preview output formats and compare related sample variants.

Как это работает

  1. 1Open a sample entry to inspect the prepared example payload or asset.
  2. 2Compare it with related tools to understand how the workflow connects.

Сценарии использования

  • Преобразование Формата Даты
  • Форматирование Номера Телефона
  • Преобразование Регистра Текста
  • Нормализация URL
  • Обфускация Электронной Почты
  • Удаление и Преобразование HTML-тегов

FAQ

What is included in Примеры Замены Regex?

This page includes curated sample entries, related tools, and neighboring sample collections for Примеры Замены Regex.

Главная
Инструменты3197
Примеры593
Визуализации461
Средства просмотра файлов103
Темы229
Теги333
Изображения, аудио и видео655

Инструменты для обработки, конвертации и оптимизации изображений, аудио и видео

Математика, даты и финансы644

Калькуляторы, числовые инструменты, логика дат, статистика и финансы

Дизайн и цвет296

Инструменты для цвета, макетов, графики, визуального стиля и дизайна

Текст и письмо209

Инструменты для письма, очистки, форматирования, извлечения и анализа текста

Разработка и Web193

Инструменты разработчика, сетевые утилиты, веб-отладка и автоматизация

Преобразование и кодирование175

Инструменты для преобразования форматов, файлов, архивов, единиц и кодировок

Структура интерфейса по скриншоту: проверка и передача разработчику
Фортепианный эскиз: создание, проверка MIDI и передача аудиодемо
Проверка ретро-текстур и передача игровых ресурсов
Проверка и передача пошагового руководства со снимками
Визуальная проверка адаптивной страницы после редизайна

© 2026 Elysia Tools. Все права защищены.

ДокументацияТарифыО насУсловия использованияПолитика конфиденциальностиCookieКонтакты

Media

Конвертер MOV в MP4

Конвертирует видеофайлы MOV в формат MP4

Media

Конвертер MP4 в MOV

Конвертирует видеофайлы MP4 в формат MOV

Media

Пакетный Конвертер Видео

Конвертируйте несколько видеофайлов между различными форматами, такими как MP4, WebM, MKV, AVI, MOV с настройками качества и пакетной обработкой

Media

Видео в GIF Оптимизированный

Конвертирует видео в оптимизированный формат GIF с расширенными настройками сжатия

Media

Умный remux

Перепаковывает контейнеры через stream copy.

Development

Предпросмотр Замены Regex

Предпросмотр замен regex в реальном времени с выделением различий и статистикой

Media

Редактор Видео

Точная нарезка и обрезка видеоклипов с поддержкой различных форматов и настроек качества

Media

Горизонтальный Флип Видео

Зеркально переворачивает видео, сохраняя исходный контейнер и по возможности аудио без перекодирования

Обработка текста

Примеры Дублирующихся Строк

Примеры файлов с различными типами дублирующихся строк для тестирования инструментов удаления дубликатов

C#

Обработка Строк Windows - Примеры C#

Полные примеры обработки строк на C# для платформы Windows, включая манипуляцию, разделение, объединение, регулярные выражения и анализ текста

Обработка текста

Примеры текста с эмодзи

Многоязычный текст, содержащий различные эмодзи Unicode для тестирования извлечения эмодзи

Обработка текста

Примеры Специальных Символов

Примеры текстовых файлов с различными специальными символами, знаками пунктуации и символами для тестирования удаления неалфавитно-цифровых символов

Обработка кода

Примеры Комментариев Кода

Примеры кода с различными стилями комментариев для тестирования удаления комментариев

Обработка текста

Именованные Захватывающие Группы Regex

Коллекция паттернов регулярных выражений, использующих именованные захватывающие группы для извлечения структурированных данных из текста. Именованные группы делают паттерны более читаемыми и поддерживаемыми, присваивая значимые имени захваченным частям.