Understanding JavaScript RegExp: Example based guide to mastering JavaScript regular expressions

Understanding JavaScript RegExp: Example based guide to mastering JavaScript regular expressions

Understanding JavaScript RegExp: Example based guide to mastering JavaScript regular expressions
Автор: Agarwal Sundeep
Дата выхода: 2023
Издательство: Lean Publishing
Количество страниц: 83
Размер файла: 561.0 KB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

Preface....5

Prerequisites....5

Conventions....5

Acknowledgements....5

Feedback and Errata....6

Author info....6

License....6

Book version....6

Why is it needed?....7

How this book is organized....8

RegExp introduction....9

Console and documentation....9

test() method....9

Flags....10

RegExp constructor and reuse....10

replace() method....11

Cheatsheet and Summary....12

Exercises....12

Anchors....15

String anchors....15

Line anchors....16

Word anchors....17

Opposite Word Anchor....18

Cheatsheet and Summary....19

Exercises....19

Alternation and Grouping....22

Alternation....22

Grouping....22

Precedence rules....23

Cheatsheet and Summary....24

Exercises....24

Escaping metacharacters....26

Escaping with backslash....26

Dynamically escaping metacharacters....26

Dynamically building alternation....27

source and flags properties....28

Escaping the delimiter....28

Escape sequences....28

Cheatsheet and Summary....30

Exercises....30

Dot metacharacter and Quantifiers....32

Dot metacharacter....32

split() method....32

Greedy quantifiers....33

AND Conditional....35

What does greedy mean?....35

Non-greedy quantifiers....36

s flag....37

Cheatsheet and Summary....37

Exercises....38

Interlude: Tools for debugging and visualization....42

regex101....42

regulex....42

regexcrossword....43

Summary....43

Working with matched portions....44

match() method....44

search() method....44

Capture groups....45

d flag....45

Getting all the matched portions....46

matchAll() method....46

split() with capture groups....47

Using functions in the replacement section....48

Using dictionary in the replacement section....49

Cheatsheet and Summary....50

Exercises....50

Character class....54

Custom character sets....54

Range of characters....54

Negating character sets....54

Matching metacharacters literally....55

Escape sequence sets....56

Numeric ranges....56

Cheatsheet and Summary....57

Exercises....57

Groupings and backreferences....61

Backreferences....61

Backreference oddities....62

Non-capturing groups....63

Named capture groups....64

Cheatsheet and Summary....65

Exercises....65

Interlude: Common tasks....69

CommonRegexJS....69

Summary....69

Lookarounds....70

Conditional expressions....70

Negative lookarounds....70

Positive lookarounds....71

Capture groups inside positive lookarounds....72

AND conditional with lookarounds....73

Variable length lookbehind....73

Negated groups....73

Cheatsheet and Summary....74

Exercises....74

Unicode....79

Unicode character sets and the u flag....79

v flag....79

Codepoints....80

Cheatsheet and Summary....80

Exercises....81

Further Reading....83

Scripting and automation tasks often need to extract particular portions of text from input data or modify them from one format to another.

This book will help you learn JavaScript Regular Expressions, a mini-programming language for all sorts of text processing needs.

The book heavily leans on examples to present features of regular expressions one by one. It is recommended that you manually type each example and experiment with them.

Exercises are included to test your understanding. Reference solutions are also provided.

Prerequisites

You should be familiar with programming basics. You should also have a working knowledge of JavaScript syntax and functional programming concepts like map and filter.

You are also expected to get comfortable with reading documentation, searching online, visiting external links provided for further reading, tinkering with illustrated examples, asking for help when you are stuck and so on. In other words, be proactive and curious instead of just consuming the content passively.


Похожее:

Список отзывов:

Нет отзывов к книге.