80 likes | 204 Vues
This guide explores the fundamentals of regular expressions (regex), focusing on metasymbols and syntax for matching patterns in text. Learn how to find specific strings within larger texts using examples, including the matching of words with specific characteristics and sequences. Discover how to use symbols like w and d for character and digit matching, and explore quantifiers to specify the number of occurrences. With practical examples ranging from basic to advanced applications, this resource is essential for anyone looking to master text pattern matching.
E N D
EXAKT Regular Expressions
Content Regular Expressions Examples Metasymbols and syntax
Regular Expressions Patterns for describing sets of symbol strings with the help of meta symbols and a predefined syntax Purpose: find strings in larger strings / texts
Examples The words this, that, those and these and their capitalized variants [Tt]h(is|at|ose|ese) Words starting with in and ending in able or ably (e.g. indisputable, indescribably, ineffable, indistinguishable etc.) \bin[a-z]+abl[ey]\b All sequences of three words followed by a question mark, i.e. the last three words of questions (\b[A-Za-z]+\b){3,3}\?
Meta symbols and syntax Examples: B[ui]rma matches „Burma“ and „Birma“ M[ae][iy]er matches „Maier“, „Mayer“, „Meyer“, „Meier“, Symbols and symbol classes:
Meta symbols and syntax Important!!! \w matches letters of the English alphabet, no extensios of the Latin alphabet Instead: [A-Za-zÄäÖöÜüß]for the German alphabet Predefined symbol classes (selection):
Meta symbols and syntax Examples: [A-K]\w+ matches words with capital initial A-K \d{1,2}\.\d{1,2}\.\d{2,4} matches dates (14.11.1971) Quantifiers:
Meta symbols and syntax Beispiele: \. matches a period [Dd](er|ie|as) matches German definite articles [a-z0-9-_\.]+@[a-z0-9-_\.]+\.\w{2,3} matches email adresses Other metasymbols (selection):