Skip to main content
✍️ How to Write Regular Expressions
Yoom Customer Service avatar
Written by Yoom Customer Service
Updated over 4 weeks ago

📝 Overview

Regular expressions (regex) are powerful tools used for data extraction, replacement, and transformation.

In Yoom, you can utilize regex within data transformation operations like “Replace” and “Extract” to handle complex data patterns.

To perform these operations, you need to define patterns using regular expressions.


📖 Regular Expression Syntax Examples

Below are practical examples of regular expressions for data extraction and their corresponding results.

📍 Sample Base Data

Dear Yoom Users,

We hope this email finds you well.
This is Yoom Inc.

This is a test message for regular expressions.
Thank you for your attention.

[Regular Expression Test Text]
ーーーーーーーーーーーーーーーーーー
・Mobile Phone: 090-1234-5678
・Mobile Phone: 09012345678
・Landline: 03-1234-5678
・Toll-Free: 0120-123-456
ーーーーーーーーーーーーーーーーーー
・Postal Code: 101-0054
・Address: KANDA SQUARE 11F, 2-2-1 Kanda Nishikicho, Chiyoda-ku, Tokyo
ーーーーーーーーーーーーーーーーーー
・2019/01/23
・2019-01-23
ーーーーーーーーーーーーーーーーーー
・15:15
ーーーーーーーーーーーーーーーーーー
・This is a (Sample).

Yoom Operations Office
Mail: cs_yoom@yoom.fun
URL: https://yoom.fun
Office: KANDA SQUARE 11F, 2-2-1 Kanda Nishikicho, Chiyoda-ku, Tokyo

📍 Examples of Regular Expressions and Their Results

Data to Extract

Regular Expression

Example Output

Email address

[\w\-\._]+@[\w\-\._]+\.[A-Za-z]+

Domain

([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}

yoom.fun

Mobile phone number

0[6-9]0-\d{4}-\d{4}

090-1234-5678

Mobile number (no dashes)

0[6-9]0\d{8}

09012345678

Landline number

0\d(-\d{4}|\d-\d{3}|\d\d-\d\d|\d{3}-\d)-\d{4}

03-1234-5678

Toll-free number

(0120|0800)-\d{3}-\d{3}

0120-123-456

URL

https?://[\w!\?/\+\-_~=;\.,\*&@#\$%\(\)'\[\]]+

Date (/ format)

\d{4}/\d{1,2}/\d{1,2}

2019/01/23

Date ( - format)

\d{4}-\d{1,2}-\d{1,2}

2019-01-23

Time (: format)

((0?|1)[0-9]|2[0-3]):[0-5][0-9]?

15:15

Text after a specific String

(?<=Office:)(.*)

KANDA SQUARE 11F, 2-2-1 Kanda Nishikicho, Chiyoda-ku, Tokyo

Text between two strings

(?<=Office:)(.*)(?= Tokyo)

KANDA SQUARE 11F, 2-2-1 Kanda Nishikicho, Chiyoda-ku,

Text inside ( )

\(.+?\)

(Sample)


💡 Advanced Regular Expression Techniques

1. Escaping Meta Characters

In regular expressions, certain characters have special meanings and need to be escaped with a backslash (\) if you want to use them as normal characters.

Meta Characters

.  ^  $  [  ]  *  +  ?  |  (  )  \  /

📍 Example:

To extract 2023-05-01 from this string:

2023-05-01(Mon) use this regex to exclude (Mon).

(.*)(?=\()
  • \( → Escapes the parenthesis to treat it as a normal character.

2. Extracting Text After Line Breaks

Use \n to represent line breaks in regular expressions.

📍 Example:

Extract 「Name:John Yoom」from:

Company Name: Yoom Corp.
Name: John Yoom
Address:Tokyo

Regex:

(?<=\n)(.*)(?=\nAddress)
  • (?<=\n) → Extract after a line break

  • (.*) → Captures the desired text

  • (?=\nAddress) → Stops extraction before "Address"

3. Extracting Multiple Text (Including Line Breaks)

To capture text that spans multiple lines, use [sS] to include all characters (including line breaks).

📍 Example:

Extract “This is a remark.”

Note
This is
a remark.

Company
Yoom Inc.

Regex:

(?<=Note)([\s\S]*)(?=Company)
  • (?<=Note) → Starts after "Note"

  • ([\s\S]*) → Matches any characters, including line breaks

  • (?=Company) → Stops before "Company"


📚 Related Guides

  • List of Help Pages Regarding Regular Expressions - View Guide

Did this answer your question?