रेगेक्स परीक्षक

रियल-टाइम सत्यापन के साथ नियमित अभिव्यक्तियों का उपयोग करके टेक्स्ट का परीक्षण, मैच, प्रतिस्थापन और विभाजन करें

नियमित अभिव्यक्ति पैटर्न

//gवैध

परीक्षण स्ट्रिंग

वर्ण: 0लाइनें: 1

परिणाम

रेगेक्स त्वरित संदर्भ

वर्ण श्रेणियां

\\d - Digits (0-9)
\\w - Word characters
\\s - Whitespace
. - Any character

मात्रा निर्धारक

* - 0 or more
+ - 1 or more
? - 0 or 1
{n,m} - Between n and m

एंकर

^ - Start of string
$ - End of string
\\b - Word boundary
\\B - Non-word boundary

रेगेक्स टेस्टर - ऑनलाइन रेगुलर एक्सप्रेशन जांचें

Online regex tester एक शक्तिशाली डेवलपर टूल है जो आपको regular expressions को design, debug और समझने में instant feedback देता है। इसका उपयोग email validation, ID extraction, whitespace normalization, logs parse करने या safe search-and-replace के लिए करें। Real-time highlighting और clear examples के साथ आप character classes, groups, quantifiers, anchors और lookarounds जैसे core concepts आसानी से सीख सकते हैं। यह पेज रोज़मर्रा के practical use cases पर फोकस करता है और performance issues से बचते हुए readable और maintainable regex लिखना सिखाता है।

Regex basics: patterns, flags और character classes

Regular expression strings के set को describe करता है। Common elements: dot (.) किसी भी character से match करता है, anchors (^) और ($) start और end को match करते हैं, quantifiers (* + ? {m,n}) repetition नियंत्रित करते हैं, character classes ([a-z], \d, \w, \s) category match करती हैं, groups (( ... )) substrings capture करते हैं, और alternation (a|b) multiple options चुनता है। Flags जैसे g (global), i (ignore case), m (multiline), s (dotall), और u (Unicode) search behavior बदलते हैं। इनसे powerful validation और text processing patterns बनाए जा सकते हैं।

Practical patterns जिन्हें आप तुरंत उपयोग कर सकते हैं

Email validation (basic check): ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ सामान्य email formats handle करता है। URL check: ^https?:\/\/[^\s/$.?#].[^\s]*$ http/https links filter करता है। ISO date: ^\d{4}-\d{2}-\d{2}$ YYYY-MM-DD format match करता है। Whitespace normalize करने के लिए \s{2,} को global replace करें। Issue ID extract करने के लिए /(PROJ-\d+)/ pattern उपयोग करें। इन्हें starting point की तरह लें और अपने domain के अनुसार refine करें।

Step-by-step: build, test और refine करें

Concrete example से शुरू करें। पहले literal characters जोड़ें, फिर character classes और quantifiers से generalize करें। Anchors जोड़कर match location सीमित करें और capture groups से required data extract करें। Tester में matches और groups inspect करें। अगर pattern over-match करे तो quantifier lazy (.*?) बनाएं या class specific करें। Under-match होने पर class relax करें। Iteration से stable behavior प्राप्त करें।

Boundaries, lookarounds और Unicode support

Word boundary (\b) उपयोगी है, लेकिन सभी engines Unicode-aware नहीं होते। u flag का उपयोग करें। Lookahead (?=...) और lookbehind (?<=...) context check करते हैं बिना characters consume किए। उदाहरण: currency symbol से पहले digits match करना। कुछ पुराने runtimes में lookbehind support नहीं होता—target environment में verify करें।

Performance और catastrophic backtracking

Nested quantifiers catastrophic backtracking का कारण बन सकते हैं, जिससे performance slow हो जाती है। जैसे (a+)+ या (.*)+ जैसी patterns बड़े strings पर problematic होती हैं। Fast regex के लिए: (1) specific character classes उपयोग करें, (2) nested star/plus avoid करें, (3) atomic groups या possessive quantifiers उपयोग करें जहाँ उपलब्ध हों, (4) anchors से search space सीमित करें। Production से पहले large test cases पर test करें।

Search-and-replace सुरक्षित तरीके से

Rewrite jobs में capture groups और backreferences thoroughly test करें। उदाहरण: 'Doe, Jane' को swap करने के लिए ^([^,]+),\s*(.+)$ और replacement $2 $1 उपयोग करें। Different languages में $1, \1 या named groups अलग behave कर सकते हैं। Multi-line edits के लिए multiline flag enable करें। Bulk replace से पहले backup रखें।

Testing strategy और maintainability

Regex को code की तरह treat करें। Positive और negative examples के साथ unit tests लिखें। Tricky parts पर comments जोड़ें। Cleverness से ज्यादा clarity चुनें। यदि pattern business rules encode करता है (जैसे SKU format), तो intent document करें ताकि future maintainers सुरक्षित रूप से update कर सकें।

Further reading

Regex tester का उपयोग safely iterate करने, patterns document करने और simple तथा specific expressions बनाने के लिए करें। Clear character classes और anchored searches speed और correctness के बीच संतुलन बनाए रखते हैं।

Advertisement