Автор: Faraz K. Kelhini
Издательство: Pragmatic Bookshelf
Год: 2024
Страниц: 242
Язык: английский
Формат: pdf, epub (true)
Размер: 10.9 MB
You might think of regular expressions as the holy grail of text processing, but are you sure you aren't just shoehorning them in where standard built-in solutions already exist and would work better? jаvascript itself provides programmers with excellent methods for text manipulation, and knowing how and when to use them will help you write more efficient and performant code. From extracting data from APIs to calculating word counts and everything in between, discover how to pick the right tool for the job and make the absolute most of it every single time.
Whether you're a beginner or an advanced programmer, this up-to-date guide will save you a ton of time when dealing with text. With Text Processing with jаvascript, you'll find a collection of tiny programs, each demonstrating a string manipulation approach in jаvascript. You'll also focus squarely on the practical aspects of text processing with jаvascript - that is, what each technique is designed to accomplish and how to use it in your program.
Most popular programming languages support regular expressions, and there’s a good reason for that: regular expressions are incredibly powerful at text processing. With regular expressions, you can greatly reduce the time and effort required for complex string parsing tasks that would otherwise take dozens of lines of code. But, as a jаvascript developer, you may not need to jump into writing regular expression patterns whenever you need to process texts. jаvascript already provides excellent built-in tools that meet many of your text manipulation needs. In this book, you’ll explore when and how to use each tool by working through real-world scenarios. You’ll learn the mechanics of jаvascript’s regex in detail via cookbook-style recipes for various text manipulation tasks.
Discover how to extract data from APIs and web pages, apply spelling corrections, convert and format currencies, and remove HTML tags from text. Learn to intersect tables, copy text to the clipboard, extract lists from text, and highlight sentences that contain a specific word. Find duplicate words and fix them automatically, modify a copy of an existing regex literal, match the beginning or end of a string, and remove all comments from jаvascript and HTML files with ease. Match non-ASCII words, calculate the word count of an article in any language, and more.
Become a jаvascript expert and master chef of text processing with this collection of hands-on and production-ready recipes.
Who Is This Book For?
This book is geared toward the needs of both client- and server-side programmers. Whether you’re a beginner or an advanced programmer, this guide will save you a ton of time when dealing with textual data. We’ll focus squarely on the practical aspects of text processing with jаvascript—that is, what each technique is designed to accomplish and how to use it in your program. Readers who have experience with regular expressions will still benefit from this book as it contains a wealth of detail on jаvascript’s regular expression flavor as well as features recently introduced. By the end of this book, you will be able to solve a great many complex validation, modification, and search-and-replace problems rapidly and efficiently.
What You Should Know:
To use this book, you should already know basic jаvascript, HTML, and CSS syntax. Use of HTML and CSS will be infrequent and fairly basic, and I’ll explain each jаvascript example in detail. So even if your knowledge is rusty, you’ll understand how the code works. To run the examples, you’ll need a jаvascript environment that supports the newest version of the ECMAScript standard (ECMAScript is the official standard that defines the specification of jаvascript). So, whether you’re running the examples in your browser’s console or the Node.js environment, make sure you have the latest software version installed. Certain recipes use APIs that are only available in the browser environment, such as fetch(). As a result, you can run those recipes only in a browser. We’ll warn you about the lack of browser/environment support whenever necessary.
Скачать Text Processing with jаvascript: Regular Expressions, Tools, and Techniques for Optimal Performance