100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Programming Reference

Regex Syntax Reference

A regular expression is a pattern that describes a set of strings: literal characters match themselves, classes like \d match a kind of character, quantifiers like + say how many, and anchors like ^ and $ pin the match to a position. This reference lists every token with a pattern showing it at work.

72 entries8 categoriesFree, no sign-up

Browse by Category

All Regex Syntax (72)

Character Classes (13)

Matching a kind of character rather than a literal one.

.

Matches

Any character

Description

Matches any single character except a line break, unless the s (dotAll) flag is set.

Example

a.c → abc, axc

[abc]

Matches

One of these

Description

A character set: matches exactly one of the characters listed inside the brackets.

Example

[aeiou] → any vowel

[^abc]

Matches

None of these

Description

A negated set. The caret only negates when it is the first character inside the brackets.

Example

[^0-9] → any non-digit

[a-z]

Matches

Character range

Description

Matches any character whose code point falls in the range. Ranges can be combined in one set.

Example

[a-zA-Z0-9_]

\d

Matches

Digit

Description

Any digit 0–9. Equivalent to [0-9] in JavaScript without the u flag.

Example

\d{3} → 123

\D

Matches

Non-digit

Description

Any character that is not a digit — the complement of \d.

Example

\D+ → abc

\w

Matches

Word character

Description

A letter, digit or underscore: [A-Za-z0-9_]. Notably it does not include the hyphen.

Example

\w+ → user_1

\W

Matches

Non-word character

Description

Anything \w does not match, including spaces and punctuation.

Example

\W → " " or "!"

\s

Matches

Whitespace

Description

Space, tab, line feed, carriage return, form feed and vertical tab.

Example

\s+ → " "

\S

Matches

Non-whitespace

Description

Any character that is not whitespace. Useful for grabbing a token of unknown shape.

Example

\S+ → one word

[\s\S]

Matches

Truly any character

Description

Matches anything including newlines, which plain . does not. The portable alternative to the s flag.

Example

[\s\S]*

\p{L}

Matches

Unicode property

Description

Matches by Unicode property — L is any letter in any script. Requires the u or v flag.

Example

/\p{L}+/u → héllo

\P{L}

Matches

Negated property

Description

The complement of \p — any character without the named property. Also requires the u flag.

Example

/\P{L}/u

Anchors & Boundaries (6)

Pinning a match to a position rather than a character.

^

Matches

Start of string

Description

Asserts the position at the start of the input, or of each line when the m flag is set.

Example

^Hello

$

Matches

End of string

Description

Asserts the position at the end of the input, or of each line under the m flag.

Example

world$

\b

Matches

Word boundary

Description

The position between a word character and a non-word character. Matches a whole word rather than a substring.

Example

\bcat\b → "cat", not "category"

\B

Matches

Non-boundary

Description

Any position that is not a word boundary — matches inside a word.

Example

\Bcat\B → "concatenate"

\A

Matches

Absolute start

Description

Start of the input regardless of the multiline flag. Available in PCRE and Python; JavaScript has no equivalent.

Example

\Astart

\z

Matches

Absolute end

Description

End of the input, ignoring multiline. PCRE and Python only; \Z allows a trailing newline.

Example

end\z

Quantifiers (11)

How many times the previous token may repeat.

*

Matches

Zero or more

Description

Repeats the previous token any number of times, including none. Greedy by default.

Example

ab*c → ac, abc, abbc

+

Matches

One or more

Description

Repeats the previous token at least once.

Example

ab+c → abc, abbc

?

Matches

Zero or one

Description

Makes the previous token optional.

Example

colou?r → color, colour

{n}

Matches

Exactly n

Description

Repeats the previous token exactly n times.

Example

\d{4} → 2026

{n,}

Matches

n or more

Description

Repeats at least n times with no upper bound.

Example

\d{3,} → 123, 12345

{n,m}

Matches

Between n and m

Description

Repeats between n and m times inclusive. No space after the comma — it stops being a quantifier.

Example

\d{2,4} → 12, 1234

*?

Matches

Lazy zero or more

Description

Takes as little as possible, expanding only when the rest of the pattern fails.

Example

<.*?> → "<b>" not "<b>x</b>"

+?

Matches

Lazy one or more

Description

Same as + but stops at the first position that lets the rest of the pattern match.

Example

".+?"

??

Matches

Lazy optional

Description

Prefers not to match the optional token unless required.

Example

a??b

{n,m}?

Matches

Lazy range

Description

Repeats as few times as the range allows.

Example

\d{2,4}?

*+

Matches

Possessive

Description

Takes as much as possible and never gives any back, preventing catastrophic backtracking. PCRE and Java; not in JavaScript.

Example

\d*+

Groups & Alternation (7)

Capturing, grouping and choosing between branches.

(…)

Matches

Capturing group

Description

Groups tokens and captures what they matched, numbered from 1 in order of opening bracket.

Example

(\d{4})-(\d{2})

(?:…)

Matches

Non-capturing group

Description

Groups without capturing. Use it whenever you only need the grouping — it keeps numbering clean and is marginally faster.

Example

(?:ab)+

(?<name>…)

Matches

Named group

Description

Captures under a name, so results are read as match.groups.name instead of by index.

Example

(?<year>\d{4})

|

Matches

Alternation

Description

Matches the branch on the left or the right. Has the lowest precedence, so it usually needs bracketing.

Example

(cat|dog)s?

\1

Matches

Backreference

Description

Matches the same text a previous group captured — how you find a repeated word or a matching quote.

Example

(\w+) \1 → "the the"

\k<name>

Matches

Named backreference

Description

Backreference by group name rather than number.

Example

(?<q>["']).*?\k<q>

$1

Matches

Replacement reference

Description

In a replacement string, inserts what group 1 captured. $<name> works for named groups, $& for the whole match.

Example

replace(/(\w+) (\w+)/, '$2 $1')

Lookaround (5)

Asserting what follows or precedes without consuming it.

(?=…)

Matches

Positive lookahead

Description

Asserts what follows without consuming it, so the matched text excludes the assertion.

Example

\d+(?= ?kg) → "80" in "80kg"

(?!…)

Matches

Negative lookahead

Description

Asserts that what follows does not match. The usual way to exclude one case from a broad pattern.

Example

\d+(?!px)

(?<=…)

Matches

Positive lookbehind

Description

Asserts what precedes the position. Supported in modern JavaScript, PCRE and Python.

Example

(?<=£)\d+ → "50" in "£50"

(?<!…)

Matches

Negative lookbehind

Description

Asserts that what precedes does not match.

Example

(?<!£)\d+

(?=.*x)

Matches

Stacked lookahead

Description

Several lookaheads at one position test independent conditions — the standard password-rule idiom.

Example

^(?=.*\d)(?=.*[a-z]).{8,}$

Escapes & Unicode (9)

Literal specials, control characters and code points.

\.

Matches

Literal dot

Description

Escapes a metacharacter so it matches itself. The same applies to \* \+ \? \( \[ \{ \| \^ \$ \\

Example

example\.com

\n

Matches

Line feed

Description

Matches a newline character, code point 10.

Example

line1\nline2

\r

Matches

Carriage return

Description

Code point 13. Windows line endings are \r\n, so a pattern anchored with $ can trip on the stray \r.

Example

\r\n

\t

Matches

Tab

Description

Matches a horizontal tab, code point 9.

Example

name\tvalue

\0

Matches

Null character

Description

Matches the null byte, code point 0.

Example

\0

\xhh

Matches

Hex code point

Description

Matches the character with the given two-digit hexadecimal code.

Example

\x41 → A

\uhhhh

Matches

Unicode code point

Description

Matches a character by four-digit hex code point.

Example

\u00e9 → é

\u{hhhh}

Matches

Full code point

Description

Matches a code point above U+FFFF as a single unit. Requires the u flag.

Example

/\u{1F600}/u → 😀

\Q…\E

Matches

Literal block

Description

Treats everything between as literal text. PCRE and Java only; in JavaScript escape each character instead.

Example

\Qa.b*c\E

Flags & Modifiers (9)

Options that change how the whole pattern behaves.

g

Matches

Global

Description

Finds every match rather than stopping at the first. In JavaScript it also gives the regex a persistent lastIndex, so reusing one across test() calls alternates results.

Example

/\d+/g

i

Matches

Case-insensitive

Description

Ignores case throughout the pattern, including inside character sets.

Example

/hello/i → HELLO

m

Matches

Multiline

Description

Makes ^ and $ match at every line break instead of only at the ends of the input.

Example

/^error/gm

s

Matches

Dot matches all

Description

Lets . match line breaks too. Equivalent to writing [\s\S] where the flag is unavailable.

Example

/<div>.*<\/div>/s

u

Matches

Unicode

Description

Treats the pattern as code points rather than UTF-16 units, and enables \p{…} and \u{…}. Needed for emoji and non-Latin scripts.

Example

/\p{Script=Tamil}+/u

y

Matches

Sticky

Description

Matches only at exactly lastIndex, never scanning forward. The flag tokenisers use to consume input strictly in order.

Example

/\d+/y

v

Matches

Unicode sets

Description

A stricter successor to u that adds set operations such as intersection and difference inside character classes.

Example

/[\p{L}--\p{Ascii}]/v

d

Matches

Has indices

Description

Adds match.indices giving the start and end offset of every group, not just its text.

Example

/(\d+)/d

(?i)

Matches

Inline flag

Description

Turns a flag on partway through a pattern. Supported in PCRE, Python and Go; JavaScript has no inline flags.

Example

(?i)hello

Common Patterns (12)

Ready-made patterns for everyday validation.

^[^@\s]+@[^@\s]+\.[^@\s]+$

Matches

Email (loose)

Description

A deliberately permissive check: one @ with content either side and a dot in the domain. Strict RFC 5322 patterns reject valid addresses — confirm by sending mail instead.

^https?:\/\/[^\s/$.?#].[^\s]*$

Matches

URL

Description

Matches an http or https URL with a plausible host. For anything load-bearing, parse with the URL constructor rather than a pattern.

Example

https://example.com/a?b=1

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{12,}$

Matches

Strong password

Description

Stacked lookaheads require each character class independently, then the length is checked once. Length matters far more than composition — prefer 12 or more.

Example

Tr0ub4dor&3xyz

^\d{4}-\d{2}-\d{2}$

Matches

ISO date

Description

Matches the YYYY-MM-DD shape. It does not validate the date — 2026-02-31 passes, so parse afterwards.

Example

2026-06-09

^(?:\+91[\s-]?)?[6-9]\d{9}$

Matches

Indian mobile

Description

Ten digits starting 6–9, with an optional +91 country code.

Example

+91 98765 43210

^[A-Z]{5}\d{4}[A-Z]$

Matches

PAN number

Description

The Indian Permanent Account Number format: five letters, four digits, one letter.

Example

ABCDE1234F

^(?:\d{1,3}\.){3}\d{1,3}$

Matches

IPv4 (shape)

Description

Checks the four-octet shape only — 999.1.1.1 passes. Add a range check, or validate with a parser.

Example

192.168.1.1

^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Matches

Hex colour

Description

Matches three- or six-digit hex colours, with the hash optional.

Example

#1e293b

^[a-z0-9]+(?:-[a-z0-9]+)*$

Matches

URL slug

Description

Lowercase alphanumerics separated by single hyphens, with no leading or trailing hyphen.

Example

git-commands-reference

^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$

Matches

UUID

Description

A canonical UUID with version 1–5 and a valid variant nibble.

Example

3f2504e0-4f89-11d3-9a0c-0305e82c3301

\s+$

Matches

Trailing whitespace

Description

Finds trailing spaces and tabs. With the m and g flags it cleans a whole file at once.

Example

/\s+$/gm

(\b\w+\b)\s+\1

Matches

Repeated word

Description

A backreference catching an accidentally doubled word — a proofreading pattern.

Example

the the

Frequently Asked Questions

What is the difference between greedy and lazy quantifiers?

A greedy quantifier like .* takes as much as it can and gives characters back only if the rest of the pattern fails. Adding a ? makes it lazy — .*? takes as little as possible and expands only as needed. On <b>a</b><b>b</b>, <.*> matches the whole string while <.*?> matches just <b>.

How do I match a literal dot or slash?

Escape it with a backslash: \. matches a literal dot, and \/ a slash inside a /pattern/ literal. Inside a character class most specials lose their meaning, so [.] also matches a literal dot without an escape.

Should I validate email addresses with a regex?

Only loosely. The full RFC 5322 grammar is not worth expressing as a pattern, and strict regexes reject valid addresses. Check for one @ with something either side and a dot in the domain, then confirm the address by sending mail to it — that is the only real validation.

What does the g flag actually do?

It makes the regex find every match rather than stopping at the first. In JavaScript it also gives the object a lastIndex that persists between calls, so reusing a single /g/ regex across test() calls yields alternating results — create a fresh regex or reset lastIndex when that bites.

Related Reading

#Regex#RegularExpressions#Programming#TextProcessing#PatternMatching#SoftwareDevelopment#Coding#DeveloperSkills#QuickReference#DeveloperReference#KnowledgeHub#SkillVeris#RegexReference#RegexQuantifiers#RegexLookahead#RegexFlags#RegexExamples

Frequently Asked Questions

21 categories · pick one to explore

What is SkillVeris?
SkillVeris is a completely free tech-upskilling platform offering 37 live courses across AI/ML, programming, web development, DevOps, cloud, security and databases. It combines structured courses of 24–40 lessons, a 24/7 AI Mentor, and a unique Learn Through Hobbies method that explains technical concepts through cricket, music, gaming, cooking and more. It is powered by Sri Hayavadhana.
Is SkillVeris really a free learning platform?
Yes, SkillVeris is genuinely free. Every course, assessment, certificate, study note, cheat sheet and the AI Mentor are available at no cost. There are no hidden paywalls, trial periods or premium tiers locking away lessons. The platform was built to make quality tech education accessible to learners in India and worldwide without financial barriers.
Who is SkillVeris for?
SkillVeris is for anyone learning technology skills: complete beginners starting to code, students preparing for placements, working professionals switching into AI, DevOps or cloud roles, and hobbyists exploring new tools. Courses span beginner to advanced levels, and the Learn Through Hobbies method makes complex topics approachable even if you have no technical background at all.
What makes SkillVeris different from other online learning platforms?
SkillVeris stands out with its Learn Through Hobbies method, which teaches every concept through analogies from cricket, music, gaming, cooking and eight more domains you can switch instantly. Add a free 24/7 AI Mentor, structured courses of 24–40 lessons with certificates, Code Lab for in-browser practice, and a live jobs portal, all completely free of charge.
What can I learn on SkillVeris?
You can learn AI and machine learning, Python, programming fundamentals, web development, DevOps, cloud computing, security and databases through 37 live courses. Beyond courses, SkillVeris offers study notes, cheat sheets, a glossary of roughly 2,000+ terms, 500+ blog articles, interview questions with readiness scoring, and Code Lab supporting six programming languages.
Does SkillVeris offer personalized learning?
Yes, personalization is central to SkillVeris. You choose the analogy domain that matches your interests, cricket, gaming, music, cooking and more, and lessons instantly adapt their explanations. The AI Mentor answers your questions at Quick, Detailed or Deep-dive depth, and learning paths guide you toward specific careers like AI Engineer or DevOps Engineer.
Do I need any prior experience to start learning on SkillVeris?
No prior experience is needed. Many SkillVeris courses are designed for absolute beginners, starting from fundamentals and building up gradually across 35 structured lessons. The Learn Through Hobbies analogies explain technical ideas using everyday interests, so newcomers grasp concepts faster. Intermediate and advanced courses are also available when you are ready to progress.
How do I get started with SkillVeris?
Simply visit skillveris.com, create a free account, and pick a course from the Topics page or follow a learning path like AI Engineer or Full Stack Java Developer. Choose your favourite analogy domain, work through the lessons, pass the module assessments and final exam, and earn your certificate, all without paying anything.
Is SkillVeris available in India?
Yes, SkillVeris is fully available in India and is built with Indian learners strongly in mind. All 37 courses, certificates and tools are free, and the jobs portal aggregates live roles across India alongside the UK, USA, Germany and remote positions, with salary and experience filters to help you find relevant opportunities.
Can I use SkillVeris on my mobile phone?
Yes, SkillVeris works in any modern mobile browser, so you can read lessons, switch analogy domains, ask the AI Mentor questions and take assessments from your phone. The platform is designed to load fast on mobile connections, making it practical to learn during commutes or short breaks without needing a laptop.
What is the Learn Through Hobbies method on SkillVeris?
Learn Through Hobbies is SkillVeris's signature teaching approach: every key concept is explained through analogies drawn from twelve domains including cricket, music, gaming, cooking, fitness, travel and finance. You pick the domain you love and can switch instantly, so abstract topics like machine learning pipelines feel familiar rather than intimidating.
Does SkillVeris have an AI tutor?
Yes, SkillVeris includes a built-in AI Mentor available 24/7. You can ask it any question about your lessons or technology in general and choose the depth of the answer: Quick for a fast summary, Detailed for a fuller explanation, or Deep-dive for a thorough walkthrough. It is free for every learner.
Does SkillVeris help with job hunting?
Yes, SkillVeris has a jobs portal aggregating live roles across India, the UK, USA, Germany and remote positions, with salary and experience filters. Combined with interview questions featuring readiness scoring, career-focused learning paths and free certificates you can share, the platform supports your job search from skill-building through to applications.
What learning paths does SkillVeris offer?
SkillVeris offers career-oriented learning paths such as AI Engineer, DevOps Engineer and Full Stack Java Developer, among others. Each path sequences relevant courses in a logical order so you build skills progressively toward a specific role, rather than guessing which course to take next. All path courses are free and include certificates.
How much time do I need to complete a SkillVeris course?
It depends on your pace. Structured courses contain 24–40 lessons (most have 35) plus module assessments and a final exam, and each lesson typically takes around half an hour of focused reading and practice. Many learners finish a course in a few weeks studying part-time, while dedicated full-time learners can move considerably faster.
Can I practice coding on SkillVeris?
Yes, SkillVeris includes Code Lab, an in-browser coding environment supporting six programming languages across 15 practice categories. You can write and run code directly in your browser without installing anything, which makes it easy to reinforce what you learn in lessons immediately. Code Lab is free, like everything else on the platform.
Does SkillVeris have free study materials besides courses?
Yes, alongside courses SkillVeris offers free study notes, cheat sheets for quick revision, a glossary of roughly 2,000+ technical terms, more than 500 blog articles, and interview questions with readiness scoring. These resources complement the courses and are handy for exam preparation, interviews and quick refreshers, all at no cost.
Who powers SkillVeris?
SkillVeris is powered by Sri Hayavadhana. The platform's mission is to make high-quality technology education free and genuinely engaging, combining structured courses, an always-available AI Mentor and the Learn Through Hobbies analogy method so learners in India and around the world can upskill without cost being a barrier.
Is SkillVeris suitable for working professionals switching careers?
Yes, career switchers can follow structured learning paths like AI Engineer or DevOps Engineer, study flexibly around work using mobile-friendly lessons, and validate their progress through assessments and certificates. The jobs portal with salary and experience filters, plus interview questions with readiness scoring, helps professionals move into new tech roles confidently.
How is SkillVeris free, is there a catch?
There is no catch. SkillVeris does not charge for courses, certificates, the AI Mentor, Code Lab or any learning resource, and there are no trial expirations or locked premium content. The platform exists to make tech education accessible, particularly for learners in India and other regions where paid platforms are often out of reach.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse