सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक फ्लटर/डार्ट पैकेज जो निर्दिष्ट टेक्स्ट ब्लॉक्स के निर्माण के लिए रेगेक्स कार्यक्षमता को विस्तारित करता है, जैसे कि नेस्टेड ब्रैकेट या कस्टम डिलीमीटर। यह प्रत्येक स्वतंत्र ब्लॉक पर एक पैटर्न लागू करता है, जिससे जटिल स्ट्रिंग्स में संरचित टेक्स्ट के सटीक निष्कर्षण और रूपांतरण की अनुमति मिलती है। टेम्पलेट, एक्सप्रेशन या मार्कअप भाषाओं जैसे नेस्टेड सिंटैक्स के विश्लेषण के लिए आदर्श है। इसका कार्यान्वयन मोबाइल, वेब और डेस्कटॉप सहित कई प्लेटफॉर्म का समर्थन करता है, जिससे उन्नत टेक्स्ट संशोधन की आवश्यकता वाले क्रॉस-प्लेटफॉर्म एप्लिकेशन के लिए लचीला बनाता है।
उपयोग
नेस्टेड टेम्पलेट का विश्लेषण करना
डेलिमीटेड ब्लॉक्स से सामग्री निकालना
पुनरावृत्ति के साथ संरचित पाठ का प्रसंस्करण
कस्टम DSL का अनुप्रयोग
कोड में नेस्टेड एक्सप्रेशन का प्रबंधन
बहु-स्तरीय तारों में पाठ रूपांतरण
मुख्य विशेषताएँ
रिकर्सिव ब्लॉक आइसोलेशन
प्रत्येक ब्लॉक के लिए स्वतंत्र पैटर्न अनुप्रयोग
कस्टम विभाजकों का समर्थन
क्रॉस-प्लेटफॉर्म संगतता
सरल API एकीकरण
कुशल पाठ प्रसंस्करण
इनके लिए उपयुक्त
टेम्पलेट इंजन बनाने वाले डेवलपर्स
नेस्टेड टेक्स्ट पार्सिंग की आवश्यकता वाले उपकरण
संरचित स्ट्रिंग डेटा वाले अनुप्रयोग
DSL या भाषा पार्सर कार्यान्वयन
टेक्स्ट संपादक या कोड विश्लेषक
विचार योग्य बातें
गहराई से नेस्टेड संरचनाओं को कुशलता से हैंडल नहीं कर सकता
सावधानी से विभाजक डिज़ाइन की आवश्यकता होती है
प्रदर्शन इनपुट की जटिलता पर निर्भर करता है
पाठ-आधारित पैटर्न तक सीमित
गैर-पुनरावृत्ति विश्लेषण की आवश्यकता के लिए उपयुक्त नहीं
अत्यधिक नेस्टिंग के साथ संभावित स्टैक ओवरफ्लो
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
recursive_regex
An implementation of Dart's RegExp class that isolates delimited blocks
of text and applies the delimited pattern to each block separately.
The [RecursiveRegex] class implements Dart's [RegExp] class. As such,
it has all of the same methods as [RegExp] and can be used interchangeably
with [RegExp]s.
[RecursiveRegex] has 2 required parameters, [startDelimiter] and
[endDelimiter]. Both accept a [RegExp], must not be null, and
must not have identical patterns.
final regex = RecursiveRegex(
startDelimiter: RegExp(r'<'),
endDelimiter: RegExp(r'>'),
);
This [RecursiveRegex], if applied to a string, would capture every block
of text delimited by the < and > characters.
final input = 'a<b<c<d><e>f>g>h';
regex.allMatches(input); // ['<b<c<d><e>f>g>']
By default, only top-level blocks of delimited text are matched. To match
every block of delimited text, nested or not, [global] can be flagged true.
Delimited blocks of text are matched in the order that they're closed.
Note: [RecursiveRegex] is not optimized for parsing strings that do
not contain nested blocks of delimited text, [RegExp] would be more
efficient if you know the string doesn't contain any nested delimiters.
[prepended] & [appended] Patterns
[Pattern]s can be provided to [RecursiveRegex]'s [prepended] and [appended]
parameters to disqualify any matched set of delimiters that aren't lead and/or
followed by the provided [Pattern].
The block of text captured between the delimiters can be captured in a
named group by providing [RecursiveRegex] with a [captureGroupName].
final input = '<!ELEMENT [ some markup ]>';
final regex = RecursiveRegex(
startDelimiter: RegExp(r'<!(?<type>\w*)\s*\['),
endDelimiter: RegExp(r']>'),
captureGroupName: 'value',
);
print(regex.firstMatch(input).namedGroup('value')); // ' some markup '// Groups named within the delimiters can also be called.print(regex.firstMatch(input).namedGroup('type')); // 'ELEMENT'