Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
The v flag gives regex superpowers! It enables set notation, string properties, and better Unicode support - making complex patterns much easier to write!
// Intersection: Characters in BOTH sets
const intersection = /[\p{Script=Greek}&&[A-Z]]/v;
// Matches uppercase Greek letters
// Subtraction: Characters in first set but NOT second
const subtraction = /[\p{Letter}--[A-Z]]/v;
// Matches all letters EXCEPT uppercase A-Z
// Union (works like normal)
const union = /[a-z\p{Number}]/v;
// Matches lowercase letters OR numbers// Match specific emoji
const emojiPattern = /\p{RGI_Emoji}/v;
console.log(emojiPattern.test('π')); // true
console.log(emojiPattern.test('π')); // true
console.log(emojiPattern.test('π')); // true
console.log(emojiPattern.test('a')); // false
// Match emoji sequences (like flag emojis)
const flagPattern = /\p{RGI_Emoji_Flag_Sequence}/v;
console.log(flagPattern.test('πΊπΈ')); // true// Allow letters and numbers, but NOT special symbols
const usernamePattern = /^[\p{Letter}\p{Number}--[\p{Symbol}]]+$/v;
console.log(usernamePattern.test('alice123')); // true
console.log(usernamePattern.test('user_name')); // false (has _)
console.log(usernamePattern.test('test@user')); // false (has @)
// More readable than: /^[a-zA-Z0-9]+$/// Match only Cyrillic letters (Russian, etc.)
const cyrillicOnly = /^[\p{Script=Cyrillic}]+$/v;
console.log(cyrillicOnly.test('ΠΡΠΈΠ²Π΅Ρ')); // true
console.log(cyrillicOnly.test('Hello')); // false
console.log(cyrillicOnly.test('Ω
Ψ±ΨΨ¨Ψ§')); // false
// Match Arabic or Hebrew
const rtlPattern = /[\p{Script=Arabic}\p{Script=Hebrew}]/v;
console.log(rtlPattern.test('Ω
Ψ±ΨΨ¨Ψ§')); // true (Arabic)
console.log(rtlPattern.test('Χ©ΧΧΧ')); // true (Hebrew)// Remove all emoji from text
function removeEmojis(text) {
return text.replace(/\p{Emoji}/gv, '');
}
console.log(removeEmojis('Hello π World π'));
// Output: 'Hello World '
// Keep only text and numbers
function cleanText(text) {
return text.replace(/[^\p{Letter}\p{Number}\s]/gv, '');
}
console.log(cleanText('Hello! π World@ 123'));
// Output: 'Hello World 123'// Lowercase letters in Latin or Greek
const pattern1 = /[\p{Script=Latin}&&[\p{Lowercase_Letter}]]/v;
console.log(pattern1.test('a')); // true
console.log(pattern1.test('A')); // false
// All letters EXCEPT ASCII
const nonAscii = /[\p{Letter}--[a-zA-Z]]/v;
console.log(nonAscii.test('Γ±')); // true
console.log(nonAscii.test('a')); // false
console.log(nonAscii.test('ΠΡΠΈΠ²Π΅Ρ'[0])); // true
// Decimal digits from any script
const allDigits = /[\p{Decimal_Number}]/v;
console.log(allDigits.test('5')); // true (ASCII)
console.log(allDigits.test('ΰ₯«')); // true (Devanagari)
console.log(allDigits.test('Ω₯')); // true (Arabic-Indic)Intersection (&&), subtraction (--), union - like math!
Proper emoji support, script-specific matching
\\p{}Letter} is clearer than complex character ranges
Enhanced regex with set notation
Intersection (&&), subtraction (--)
Better emoji and script support
Latest regex enhancement