Regular Expressions — தமிழ்

</>Coding Tamilan.← JavaScript course

JavaScript · Lesson 26 / 32 · தமிழ்

Regular Expressions

கருத்தைப் புரிந்துகொள்ளுங்கள். Code-ஐ மாற்றி இயக்குங்கள். ஒரு சிறிய பயிற்சியால் கற்றதை உறுதி செய்யுங்கள்.

Detailed notesRunnable JavaScriptPractice + answer

மூலப் பாட விளக்கங்கள் தமிழில் உள்ளன. கூடுதல் concept, practice மற்றும் answer notes ஆங்கிலத்தில் உள்ளன.

01 / Understand

முக்கியக் கருத்து

A regular expression describes a text pattern. Anchors match boundaries; character classes describe allowed characters; quantifiers specify repetition.

Learning goal: Explain what the example does, predict its result, and change it to solve the practice task.

02 / Explore

விரிவான விளக்கங்கள்

Regular Expressions (RegExp)

Regular expressions என்பது strings-ல character combinations match பண்ண use ஆகுற patterns. Validation, searching, replacing-க்கு மிகவும் powerful.

JavaScript reference fragmentCODE
// Literal syntax (preferred)
const re1 = /hello/;
const re2 = /hello/gi; // g=global, i=case-insensitive

// Constructor
const re3 = new RegExp("hello", "gi");
Patternஎன்ன match பண்ணும்Example Match
.Newline தவிர எந்த character-உம்a, 1, !
\dDigit [0-9]5
\wWord char [a-zA-Z0-9_]a, Z, 3
\sWhitespacespace, tab
^String ஆரம்பம்^Hello
$String முடிவுWorld$
+One or more\d+
?Zero or onecolou?r
JavaScript reference fragmentCODE
const text = "Hello World, hello JavaScript!";

/hello/i.test(text);           // true
text.match(/hello/gi);         // ["Hello", "hello"]
text.replace(/hello/gi, "Hi"); // replaces all
text.search(/World/);          // 6

// Real-world examples
const emailRe = /^[\w.-]+@[\w.-]+\.[a-z]{2,}$/i;
console.log(emailRe.test("user@example.com")); // true
03 / Read & predict

முழுமையான உதாரணம்

Run this complete index.js program in the JavaScript console editor below. The earlier reference fragments may need a browser page or other surrounding setup.

index.js · complete exampleCODE
const courseCode = /^JS-\d{3}$/;
console.log(courseCode.test("JS-101"));
console.log(courseCode.test("JS-12"));
console.log("Lesson 12".replace(/\d+/g, "13"));
எதிர்பார்க்கும் முடிவைப் பாருங்கள்
true
false
Lesson 13
04 / Experiment

மாற்றி இயக்கிப் பாருங்கள்

Load the example, change a value, predict the output, and run it again. Use the console output to check your reasoning.

Open editor ↗

Editor load ஆனதும் code-ஐ ஏற்றி Run அழுத்துங்கள்.

OneCompiler என்ற இலவச வெளிப்புற சேவை code-ஐ இயக்குகிறது. Run செய்யும் code அங்கு அனுப்பப்படும். தனிப்பட்ட தகவல்கள் அல்லது secret keys உள்ளிட வேண்டாம்.

05 / Your turn

சிறிய பயிற்சி

Practice challenge

Test JS-999 and XJS-101.

விடை மற்றும் விளக்கம்

JS-999 matches; XJS-101 does not because ^ anchors the start.

தவிர்க்க வேண்டிய தவறு: Do not use a simple regex as your only validation for complex formats or security rules. Patterns with g can also carry lastIndex state when reused with test.

அடுத்த பாடத்திற்குத் தயாரா?

  • Explain the example in your own words.
  • Complete the challenge before revealing its answer.
  • Describe the common mistake and how to avoid it.
Coding Tamilan · Learn by doing.