How to Match decimal numbers and currency in Regex.mp4

 



Download How to Match decimal numbers and currency in Regex.mp4


Here’s a simple and easy explanation of how to match decimal numbers and currency values using Regex, along with clear examples.


✔️ Matching Decimal Numbers & Currency in Regex

Image

Image


🟦 1. Matching Decimal Numbers

Decimal numbers are numbers that may have a decimal point.

Examples:

12
12.5
0.99
.75
150.00

✅ Basic Regex for Decimal Numbers

\d+(\.\d+)?

✔️ Explanation

  • \d+ → one or more digits

  • (.\d+)? → optional decimal part

    • \. → the dot

    • \d+ → digits after the dot

    • ? → the whole decimal part is optional

✔️ Matches

  • 12

  • 12.5

  • 150.00

❌ Does NOT match

  • .75 (because it requires digits before the dot)


🟦 2. Matching Decimals With Optional Leading Zero

If you want to allow numbers like .75, use this:

✅ Regex

\d*(\.\d+)?

✔️ Matches

  • .75

  • 0.75

  • 12.9

  • 12


🟦 3. Allowing Either Integer or Decimal, but Not Empty

This is often used in real applications.
You want either:

  • digits only → 45

  • digits + decimals → 45.90

  • dot + decimals → .90

✅ Better Regex

\d+(\.\d+)?|\.\d+

🟦 4. Matching Currency Values (₹, $, €, etc.)

Currency usually has:

  • Symbol → $, , , £

  • Decimal part with exactly 2 digits → .00, .50, .99

  • Optional commas → 1,000.50

Examples:

$10.99
₹1,200.00
€0.50
£99

✔️ 4.1 Currency With Symbol & Optional Decimal

✅ Regex

[$₹€£]\d+(\.\d{2})?

✔️ Explanation

  • [$₹€£] → matches one symbol

  • \d+ → the number

  • (\.\d{2})? → optional .00 decimal part with 2 digits

✔️ Matches

  • $10

  • $10.99

  • ₹50.00

  • €9.50


✔️ 4.2 Currency With Commas (1,000.00)

✅ Regex

[$₹€£]\d{1,3}(,\d{3})*(\.\d{2})?

✔️ Explanation

  • \d{1,3} → first group (1–3 digits)

  • (,\d{3})* → optional groups of ,000

  • (.\d{2})? → optional decimal part

✔️ Matches

  • $1,000.00

  • ₹25,50,000.99 (Indian numbering also works depending on format)

  • €999.50


🟩 5. Currency Without Symbol (just numbers like 10.99)

If you want to match only valid currency decimals, exactly 2 digits:

✅ Regex

\d+(\.\d{2})?

✔️ Matches:

  • 10

  • 10.99

❌ Does NOT match:

  • 10.9

  • 10.999


🟩 6. Complete Universal Regex

Match currency numbers with optional:

  • symbol

  • commas

  • decimals

✅ Universal Regex

([$₹€£])?\d{1,3}(,\d{3})*(\.\d{2})?

🎉 Summary (Super Simple)

Purpose Regex
Basic decimal \d+(\.\d+)?
Allow .75 \d*(\.\d+)?
Currency with symbol [$₹€£]\d+(\.\d{2})?
Currency with commas [$₹€£]\d{1,3}(,\d{3})*(\.\d{2})?
Strict 2-decimal currency \d+(\.\d{2})?

Enjoy! Follow us for more... 

Explaination about Shorthand character sets.mp4



Download Explanation about Regex shortnand character sets.mp4

 Here’s a simple and clear explanation of the most common Regex shorthand character sets, with easy examples to help you understand how they work.


Regex Shorthand Character Sets (Explained Simply)

Regular expressions (regex) use shorthand character sets to make pattern-matching easier.
Instead of writing long character ranges, you can use short symbols like \d, \w, \s, etc.

Below is a friendly explanation of each.


🔹 1. \d → Digit characters

Meaning: Matches any number from 0–9

Examples:

  • Regex: \d
    Matches: 3 in "A3Z"

  • Regex: \d\d
    Matches: "45" in "Age: 45"


🔹 2. \D → Non-digit characters

Meaning: Matches anything except 0–9

Examples:

  • Regex: \D
    Matches: A in "A3"

  • Regex: \D+
    Matches: "Name" in "Name123"


🔹 3. \w → Word characters

Meaning: Matches

  • Letters (A–Z, a–z)

  • Numbers (0–9)

  • Underscore (_)

Examples:

  • Regex: \w
    Matches: a in "a!"

  • Regex: \w+
    Matches: "Hello123" in "Hello123!!"


🔹 4. \W → Non-word characters

Meaning: Matches anything except letters, numbers, and underscore

Examples:

  • Regex: \W
    Matches: ! in "Hi!"

  • Regex: \W+
    Matches: " @#" in "User @# Name"


🔹 5. \s → Whitespace characters

Meaning: Matches spaces, tabs, and newlines
(space, \t, \n)

Examples:

  • Regex: \s
    Matches the space in "Hello World"

  • Regex: \s+
    Matches " " (multiple spaces)


🔹 6. \S → Non-whitespace characters

Meaning: Matches anything that is not space, tab, or newline

Examples:

  • Regex: \S
    Matches: H in " Hello"

  • Regex: \S+
    Matches: "Hello" in "Hello World"


📌 Additional Character Class Shorthands (POSIX Style)

Some regex engines (like Linux grep -E, PHP, Perl) use POSIX character classes inside [[: ... :]].

Examples:

🔹 [:digit:] → Digits (0–9)

🔹 [:alpha:] → Alphabet letters (A–Z, a–z)

🔹 [:alnum:] → Letters + numbers

🔹 [:upper:] → Uppercase letters

🔹 [:lower:] → Lowercase letters

Example use:

[[:digit:]]+

Matches "2024" in "Year: 2024"


🎯 Summary Table (Quick View)

Shorthand Meaning Example Match
\d Digit 5
\D Not a digit A
\w Word character A, 3, _
\W Not word character !
\s Whitespace (space)
\S Non-whitespace H
[[:digit:]] Digit 7
[[:alpha:]] Letters A, z

Enjoy! Follow us for more... 

How to install nano for Windows.mp4

 


Download How to Install Nano on Windows .mp4



How to Install Nano on Windows

Nano is a lightweight, beginner-friendly text editor commonly used on Linux systems. You can use Nano on Windows too — through several methods.


Method 1: Install Nano Using Windows Subsystem for Linux (WSL)

(Recommended — easiest and most stable)

Step 1: Enable WSL

  1. Open PowerShell as Administrator

  2. Run:

wsl --install

After rebooting, Windows will install a Linux distribution (usually Ubuntu).


Step 2: Update Linux

Open the Linux terminal and run:

sudo apt update

Step 3: Install Nano

sudo apt install nano

✔ You can now run Nano in Windows through WSL:

nano filename.txt

Method 2: Install Nano Using Git for Windows

If you install Git for Windows, Nano is already included.

Step 1: Download Git

👉 https://git-scm.com/download/win

Step 2: Install Git

During installation:

  • On the "Choose your default editor" screen
    select Nano

After installation, open:

  • Git Bash

Now use:

nano test.txt

Method 3: Install Nano Using Chocolatey (Package Manager)

If you use Chocolatey:

Step 1: Install Chocolatey (if not installed)

Run PowerShell as Administrator:

Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = `
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Step 2: Install Nano

choco install nano

Run Nano:

nano filename.txt

Method 4: Portable Nano for Windows (Manual Install)

A native Windows build exists but is less maintained.

Download:

👉 https://nano-editor.org/dist/win32-support/

After extracting:

  • Open CMD in the folder

  • Run:

nano.exe file.txt

✅ Recommended Option

If you want full Linux-like behavior:
Use WSL

If you want something quick and simple:
Use Git Bash


Enjoy! Follow us for more... 

How to Match decimal numbers and currency in Regex.mp4

  Download  How to Match decimal numbers and currency in Regex.mp4 Here’s a simple and easy explanation of how to match decimal numbers and...