وبلاگ بلیان

Java 9 Regular Expressions : Solve Real World Problems Using Regex in Java.

معرفی کتاب «Java 9 Regular Expressions : Solve Real World Problems Using Regex in Java.» نوشتهٔ Anubhava Srivastava، منتشرشده توسط نشر Packt Publishing - ebooks Account در سال 2017. این کتاب در 5 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «Java 9 Regular Expressions : Solve Real World Problems Using Regex in Java.» در دستهٔ بدون دسته‌بندی قرار دارد.

Regular expressions are a powerful tool in the programmer’s toolbox and allow pattern matching. They are also used for manipulating text and data. This book will provide you with the know-how (and practical examples) to solve real-world problems using regex in Java. You will begin by discovering what regular expressions are and how they work with Java. This easy-to-follow guide is a great place from which to familiarize yourself with the core concepts of regular expressions and to master its implementation with the features of Java 9. You will learn how to match, extract, and transform text by matching specific words, characters, and patterns. You will learn when and where to apply the methods for finding patterns in digits, letters, Unicode characters, and string literals. Going forward, you will learn to use zero-length assertions and lookarounds, parsing the source code, and processing the log files. Finally, you will master tips, tricks, and best practices in regex with Java. What you will learn Understand the semantics, rules, and core concepts of writing Java code involving regular expressions Learn about the java.util.Regex package using the Pattern class, Matcher class, code snippets, and more Match and capture text in regex and use back-references to the captured groups Explore Regex using Java String methods and regex capabilities in the Java Scanner API Use zero-width assertions and lookarounds in regex Test and optimize a poorly performing regex and various other performance tips Regular expressions are a powerful tool in the programmer's toolbox and allow pattern matching. They are also used for manipulating text and data. This book will provide you with the know-how (and practical examples) to solve real-world problems using regex in Java. Preface 16 What this book covers 17 What you need for this book 18 Who this book is for 19 Conventions 20 Reader feedback 21 Customer support 22 Downloading the example code 23 Errata 24 Piracy 25 Questions 26 Getting Started with Regular Expressions 27 Introduction to regular expressions 28 A bit of history of regular expressions 29 Various flavors of regular expressions 30 What type of problems need regular expressions to solve 31 The basic rules of regular expressions 32 Constructs of the standard regular expression and meta characters 33 Some basic regular expression examples 36 Eager matching 38 The effect of eager matching on regular expression alternation 39 Summary 41 Understanding the Core Constructs of Java Regular Expressions 42 Understanding the core constructs of regular expressions 43 Quantifiers 44 Basic quantifiers 45 Examples using quantifiers 46 Greedy versus reluctant (lazy) matching using quantifiers 47 Possessive quantifiers 48 Boundary constructs 50 Examples using boundary constructs 51 Character classes 52 Examples of character classes 53 Range inside a character class 54 Examples of character range 55 Escaping special regex metacharacters and escaping rules inside the character classes 56 Escaping inside a character class 57 Examples of escaping rules inside the character class 58 Literally matching a string that may contain special regex metacharacters 59 Negated character classes 60 Examples of negated character classes 61 Predefined shorthand character classes 62 POSIX character classes 63 Unicode support in Java regular expressions 64 Commonly used Unicode character properties 65 Negation of the preceding regex directives 66 Unicode scripts support 67 Examples of matching Unicode text in regular expressions 69 Double escaping in a Java String when defining regular expressions 70 Embedded regular expression mode modifiers 71 The placement of embedded modes in a Java regular expression 73 Disabling mode modifiers 74 Summary 75 Working with Groups, Capturing, and References 76 Capturing groups 77 Group numbering 78 Named groups 80 Non-capturing groups 81 Advantages of non-capturing groups 82 Back references 83 Back reference of a named group 85 Replacement reference of a named group 86 Forward references 87 Invalid (non-existing) backward or forward references 89 Summary 90 Regular Expression Programming Using Java String and Scanner APIs 91 Introduction to the Java String API for regular expressions' evaluation 92 Method - boolean matches(String regex) 93 Example of the matches method 94 Method - String replaceAll(String regex, String replacement) 96 Examples of the replaceAll method 97 Method - String replaceFirst(String regex, String replacement) 99 Examples of the replaceFirst method 100 Methods - String split methods 101 The limit parameter rules 102 Examples of the split method 103 Example of the split method using the limit parameter 104 Using regular expressions in Java Scanner API 106 Summary 110 Introduction to Java Regular Expression APIs - Pattern and Matcher Classes 111 The MatchResult interface 112 The Pattern class 114 Examples using the Pattern class 116 Filtering a list of tokens using the asPredicate() method 119 The Matcher class 120 Examples using the Matcher class 123 Method Boolean lookingAt() 124 The matches() method 125 The find() and find(int start) methods 126 The appendReplacement(StringBuffer sb, String replacement) method 128 The appendTail(StringBuffer sb) method 129 Example of the appendReplacement and appendTail methods 130 Summary 132 Exploring Zero-Width Assertions, Lookarounds, and Atomic Groups 133 Zero-width assertions 134 Predefined zero-width assertions 135 Regex defined zero-width assertions 136 \G boundary assertion 137 Atomic groups 139 Lookahead assertions 141 Positive lookahead 142 Negative lookahead 143 Lookbehind assertions 144 Positive lookbehind 145 Negative lookbehind 146 Capturing text from overlapping matches 151 Be careful with capturing groups inside a lookahead or lookbehind atomic group 153 Lookbehind limitations in Java regular expressions 154 Summary 155 Understanding the Union, Intersection, and Subtraction of Character Classes 156 The union of character classes 157 The intersection of character classes 159 The subtraction of character classes 162 Why should you use composite character classes? 164 Summary 165 Regular Expression Pitfalls, Optimization, and Performance Improvements 166 Common pitfalls and ways to avoid them while writing regular expressions 167 Do not forget to escape regex metacharacters outside a character class 168 Avoid escaping every non-word character 169 Avoid unnecessary capturing groups to reduce memory consumption 170 However, don't forget to use the required group around alternation 171 Use predefined character classes instead of longer versions 172 Use the limiting quantifier instead of repeating a character or pattern multiple times 173 Do not use an unescaped hyphen in the middle of a character class 174 The mistake of calling matcher.goup() without a prior call to matcher.find(), matcher.matches(), or matcher.lookingAt() 175 Do not use regular expressions to parse XML / HTML data 177 How to test and benchmark your regular expression performance 178 Catastrophic or exponential backtracking 179 How to avoid catastrophic backtracking 182 Optimization and performance enhancement tips 185 Use a compiled form of regular expressions 186 Use a negated character class instead of the greedy and slow .* or .+ 187 Avoid unnecessary grouping 188 Use lazy quantifiers strategically instead of greedy quantifiers that cause excessive backtracking 189 Make use of possessive quantifiers to avoid backtracking 190 Extract common repeating substrings out of alternation 191 Use atomic group to avoid backtracking and fail fast 192 Summary 193 2017 Solve real world problems using Regex in Java. About This Book* Discover regular expressions and how they work* Implement regular expressions with Java to your code base* Learn to use regular expressions in emails, URLs, paths, and IP addressesWho This Book Is ForThis book is for Java developers who would like to understand and use regular expressions. A basic knowledge of Java is assumed. What You Will Learn* Understand the semantics, rules, and core concepts of writing Java code involving regular expressions* Learn about the java.util. Regex package using the Pattern class, Matcher class, code snippets, and more* Match and capture text in regex and use back-references to the captured groups* Explore Regex using Java String methods and regex capabilities in the Java Scanner API* Use zero-width assertions and lookarounds in regex* Test and optimize a poorly performing regex and various other performance tipsIn DetailRegular expressions are a powerful tool in the programmer's toolbox and allow pattern matching. They are also used for manipulating text and data. This book will provide you with the know-how (and practical examples) to solve real-world problems using regex in Java. You will begin by discovering what regular expressions are and how they work with Java. This easy-to-follow guide is a great place from which to familiarize yourself with the core concepts of regular expressions and to master its implementation with the features of Java 9. You will learn how to match, extract, and transform text by matching specific words, characters, and patterns. You will learn when and where to apply the methods for finding patterns in digits, letters, Unicode characters, and string literals. Going forward, you will learn to use zero-length assertions and lookarounds, parsing the source code, and processing the log files. Finally, you will master tips, tricks, and best practices in regex with Java. Style and approachThis book will take readers through this learning journey using simple, easy-to-understand, step-by-step instructions and hands-on examples at every stage Solve real world problems using Regex in Java. About This Book Discover regular expressions and how they work Implement regular expressions with Java to your code base Learn to use regular expressions in emails, URLs, paths, and IP addresses Who This Book Is For This book is for Java developers who would like to understand and use regular expressions. A basic knowledge of Java is assumed. What You Will Learn Understand the semantics, rules, and core concepts of writing Java code involving regular expressions Learn about the java.util.Regex package using the Pattern class, Matcher class, code snippets, and more Match and capture text in regex and use back-references to the captured groups Explore Regex using Java String methods and regex capabilities in the Java Scanner API Use zero-width assertions and lookarounds in regex Test and optimize a poorly performing regex and various other performance tips In Detail Regular expressions are a powerful tool in the programmer's toolbox and allow pattern matching. They are also used for manipulating text and data. This book will provide you with the know-how (and practical examples) to solve real-world problems using regex in Java. You will begin by discovering what regular expressions are and how they work with Java. This easy-to-follow guide is a great place from which to familiarize yourself with the core concepts of regular expressions and to master its implementation with the features of Java 9. You will learn how to match, extract, and transform text by matching specific words, characters, and patterns. You will learn when and where to apply the methods for finding patterns in digits, letters, Unicode characters, and string literals. Going forward, you will learn to use zero-length assertions and lookarounds, parsing the source code, and processing the log files. Finally, you will master tips, tricks, and best practices in regex with Java. Style and approach This book will take readers through this learning journey using simple, easy-to-understand, step-by-step instructions and hands-on examples at every stage Regular expressions are a powerful tool in the programmer's toolbox and allow pattern matching. They are also used for manipulating text and data. This book will provide you with the know-how (and practical examples) to solve real-world problems using regex in Java. You will begin by discovering what regular expressions are and how they work with Java. This easy-to-follow guide is a great place from which to familiarize yourself with the core concepts of regular expressions and to master its implementation with the features of Java 9. You will learn how to match, extract, and transform text by matching specific words, characters, and patterns. You will learn when and where to apply the methods for finding patterns in digits, letters, Unicode characters, and string literals. Going forward, you will learn to use zero-length assertions and lookarounds, parsing the source code, and processing the log files. Finally, you will master tips, tricks, and best practices in regex with Java. Anubhava Srivastava has more than 22 years of professional experience in architecture, design, and software development. He specializes mainly in the J2EE technology stack, web technologies, CICD, test-driven development, and AWS cloud-based development. He is an active contributor to the Stack Overflow community. He currently stands in the top 35 users in terms of reputations out of the 7.5 million Stack Overflow users. He is passionate about regular expressions and is always willing to sharpen his regex skills further. He has answered close to 10,000 regex questions on Stack Overflow. He has authored and released a test-driven framework, called GenericFixture, for FitNesse as an open source software. You can follow him on Twitter at @anubhava.
دانلود کتاب Java 9 Regular Expressions : Solve Real World Problems Using Regex in Java.