Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> C#

C# Regular Expression में Quantifiers समझाया गया


C# में Quantifiers Specify करते हैं कि Previous Element (जो Character, Group, या Character Class हो सकता है) के कितने Instances Input String में Present होने चाहिए Match के लिए।

Quantifier Description Pattern Matches
* Previous Element को Zero या More Times Match करता है। \d*\.\d ".0", "19.9", "219.9"
+ Previous Element को One या More Times Match करता है। "be+" "bee" in "been", "be" in "bent"
? Previous Element को Zero या One Time Match करता है। "rai?n" "ran", "rain"
{ n } Previous Element को Exactly n Times Match करता है। ",\d{3}" ",043" in "1,043.6", ",876", ",543", और ",210" in "9,876,543,210"
{ n ,} Previous Element को At Least n Times Match करता है। "\d{2,}" "166", "29", "1930"
{ n , m } Previous Element को At Least n Times, लेकिन No More Than m Times Match करता है। "\d{3,5}" "166", "17668" "19302" in "193024"
*? Previous Element को Zero या More Times, लेकिन As Few Times As Possible Match करता है। \d*?\.\d ".0", "19.9", "219.9"
*? Previous Element को Zero या More Times, लेकिन As Few Times As Possible Match करता है। \d*?\.\d ".0", "19.9", "219.9"
+? Previous Element को One या More Times, लेकिन As Few Times As Possible Match करता है। "be+?" "be" in "been", "be" in "bent"
?? Previous Element को Zero या One Time, लेकिन As Few Times As Possible Match करता है। "rai??n" "ran", "rain"
{ n }? Preceding Element को Exactly n Times Match करता है। ",\d{3}?" ",043" in "1,043.6", ",876", ",543", और ",210" in "9,876,543,210"
{ n ,}? Previous Element को At Least n Times, लेकिन As Few Times As Possible Match करता है। "\d{2,}?" "166", "29", "1930"
{ n , m }? Previous Element को n और m Times के बीच, लेकिन As Few Times As Possible Match करता है। "\d{3,5}?" "166", "17668" "193", "024" in "193024"

  1. जावास्क्रिप्ट रेगुलर एक्सप्रेशन मॉडिफायर्स को उदाहरण सहित समझाएं जावास्क्रिप्ट रेगुलर एक्सप्रेशन मॉडिफायर्स को उदाहरण सहित समझाएं

    परिचय जावास्क्रिप्ट रेगुलर एक्सप्रेशन मॉडिफायर्स (फ्लैग्स) रेगुलर एक्सप्रेशन का वैकल्पिक भाग होते हैं जो केस-इनसेंसिटिव और ग्लोबल सर्च करने की अनुमति देते हैं। मॉडिफायर्स को एक साथ जोड़ा भी जा सकता है। मॉडिफायर्स मॉडिफायरविवरण gग्लोबल मिलान सक्षम करता है - पहले मिलान पर रुकने के बजाय सभी मिलान

  1. - पायथन रेगुलर एक्सप्रेशन search और match में अंतर समझाएं

    re.match() और re.search() दोनों पायथन मॉड्यूल re के मेथड्स हैं। re.match() मेथड तभी मेल खाता है जब यह स्ट्रिंग की शुरुआत में होता है। उदाहरण के लिए, स्ट्रिंग TP Tutorials Point TP पर match() कॉल करना और पैटर्न TP खोजना मेल खाएगा। उदाहरण result = re.match(rTP, TP Tutorials Point TP) print result.g

  1. - पायथन रेगुलर एक्सप्रेशन सिंटैक्स को सरल तरीके से समझा सकते हैं?

    एक रेगुलर एक्सप्रेशन कैरेक्टर(एस) का एक क्रम है जिसका उपयोग मुख्य रूप से स्ट्रिंग या फाइल में पैटर्न खोजने और बदलने के लिए किया जाता है। पायथन रेगुलर एक्सप्रेशन सिंटैक्स दो प्रकार के कैरेक्टर्स का उपयोग करता है - मेटा कैरेक्टर्स: जैसा कि नाम से पता चलता है, इन कैरेक्टर्स का विशेष अर्थ होता है, वा