முழுமையான RexExp குறிப்பு
புதுப்பிக்கப்பட்ட தேதி:
ஜூலை 2025 இல் புதுப்பிக்கப்பட்டது
| பெயர் | விளக்கம் |
|---|---|
| compile() | ஒரு வழக்கமான வெளிப்பாட்டைத் தொகுக்கிறது (Deprecated) |
| constructor | RegExp முன்மாதிரியை உருவாக்கிய செயல்பாட்டை வழங்குகிறது |
| dotAll | வெளிப்பாட்டில் s கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது (புதிய 2018) |
| escape() | வழக்கமான வெளிப்பாடு தொடரியலுக்கு சொந்தமான எழுத்துகள் தப்பிக்கப்பட்ட ஒரு சரத்தை வழங்குகிறது (புதிய 2025) |
| exec() | ஒரு சரத்தில் பொருத்தங்களுக்கான முடிவு வரிசையை வழங்குகிறது |
| flags | வெளிப்பாட்டில் அமைக்கப்பட்ட மாற்றிகளை வழங்குகிறது (புதிய 2015) |
| global | வெளிப்பாட்டில் g கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது |
| hasIndices | d கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது (புதிய 2022) |
| ignoreCase | வெளிப்பாட்டில் i கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது |
| lastIndex | அடுத்த பொருத்தத்தைத் தொடங்குவதற்கான குறியீட்டைக் குறிப்பிடுகிறது |
| multiline | m மாற்றி அமைக்கப்பட்டால் true ஐ வழங்குகிறது |
| source | RegExp முறையின் உரையை வழங்குகிறது |
| sticky | வெளிப்பாட்டில் y கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது (புதிய 2015) |
| test() | ஒரு சரத்தில் பொருத்தத்தை சோதிக்கிறது. true அல்லது false ஐ வழங்குகிறது |
| toString() | வழக்கமான வெளிப்பாட்டின் சர மதிப்பை வழங்குகிறது |
| unicode | வெளிப்பாட்டில் u கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது (புதிய 2018) |
| unicodeSets | வெளிப்பாட்டில் v கொடி அமைக்கப்பட்டால் true ஐ வழங்குகிறது (புதிய 2023) |
முக்கியமான முறைகள் எடுத்துக்காட்டுகள்
exec() முறை
const pattern = /\b\w+\b/g;
const text = "Hello Jassif Team";
let result;
while ((result = pattern.exec(text)) !== null) {
console.log(`Found: ${result[0]} at ${result.index}`);
}
test() முறை
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const email = "user@jassifteam.com";
console.log(emailPattern.test(email)); // true
escape() முறை
const userInput = "[Special*Characters?]";
const escaped = RegExp.escape(userInput);
const pattern = new RegExp(escaped, 'gi');
console.log(pattern.test("Test [Special*Characters?]")); // true
பண்புகள்
const pattern = /test/gi;
console.log(pattern.global); // true
console.log(pattern.ignoreCase); // true
console.log(pattern.source); // "test"
console.log(pattern.flags); // "gi"
RegExp சரம் முறைகள்
| முறை | விளக்கம் |
|---|---|
| match(regexp) | முடிவுகளின் ஒரு வரிசையை வழங்குகிறது |
| matchAll(regexp) | முடிவுகளின் ஒரு மறுசுழற்சியை வழங்குகிறது |
| replace(regexp, s) | ஒரு புதிய சரத்தை வழங்குகிறது |
| replaceAll(regexp, s) | ஒரு புதிய சரத்தை வழங்குகிறது |
| search(regexp) | முதல் பொருத்தத்தின் குறியீட்டை வழங்குகிறது |
| split(regexp) | முடிவுகளின் ஒரு வரிசையை வழங்குகிறது |
சரம் முறைகள் எடுத்துக்காட்டுகள்
match()
const text = "Hello Jassif Team, welcome to Jassif Team";
const pattern = /Jassif Team/g;
const matches = text.match(pattern);
console.log(matches); // ["Jassif Team", "Jassif Team"]
replace()
const text = "Visit our website at example.com";
const newText = text.replace(/example\.com/, "jassifteam.com");
console.log(newText); // "Visit our website at jassifteam.com"
search()
const text = "Welcome to Jassif Team tutorials";
const position = text.search(/Jassif Team/);
console.log(position); // 11
split()
const text = "apple,banana,orange,grape";
const fruits = text.split(/,/);
console.log(fruits); // ["apple", "banana", "orange", "grape"]
நடைமுறை ஒப்பீடு
| முறை வகை | பயன்பாடு | எடுத்துக்காட்டு |
|---|---|---|
| RegExp.exec() | பொருத்த விவரங்கள் தேவைப்படும் போது | குழுக்கள், குறியீடுகள், உள்ளீடு |
| RegExp.test() | பூலியன் முடிவு மட்டும் தேவைப்படும் போது | சரிபார்ப்பு, நிபந்தனைகள் |
| String.match() | அனைத்து பொருத்தங்களும் தேவைப்படும் போது | தரவு பிரித்தெடுத்தல், எண்ணிக்கை |
| String.replace() | உரையை மாற்ற வேண்டிய போது | வடிவமைப்பு, தரவு சுத்திகரிப்பு |
| String.search() | பொருத்த நிலை தேவைப்படும் போது | சரம் பகுப்பாய்வு, உள்ளீடு சரிபார்ப்பு |
மேம்பட்ட எடுத்துக்காட்டுகள்
மின்னஞ்சல் பிரித்தெடுத்தல்
function extractEmails(text) {
const emailPattern = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g;
return text.match(emailPattern) || [];
}
ஹேஷ்டேக்குகள்
function extractHashtags(text) {
const hashtagPattern = /#\w+/g;
return text.match(hashtagPattern) || [];
}
URL சரிபார்ப்பு
function isValidURL(url) {
const urlPattern = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/\S*)?$/;
return urlPattern.test(url);
}
தொலைபேசி எண் வடிவமைப்பு
function formatPhoneNumber(phone) {
const pattern = /^(\d{3})(\d{3})(\d{4})$/;
return phone.replace(pattern, '($1) $2-$3');
}
மேலும் அறிய
Jassif Team குறிப்பு:
- JavaScript RegExp டுடோரியல்
- JavaScript RegExp கொடிகள்
- JavaScript RegExp எழுத்து வகுப்புகள்
- JavaScript RegExp மெட்டாஎழுத்துகள்
- JavaScript RegExp உறுதிப்படுத்தல்கள்
- JavaScript RegExp அளவீடுகள்
- JavaScript RegExp Patterns
- JavaScript RegExp Objects