
دانلود کتاب Regular expressions cookbook (به فارسی: کتاب آشپزی عبارات منظم) نوشته شده توسط «Jan Goyvaerts – Steven Levithan»
اطلاعات کتاب کتاب آشپزی عبارات منظم
موضوع اصلی: برنامه نویسی: زبان های برنامه نویسی
نوع: کتاب الکترونیکی
ناشر: O’Reilly
نویسنده: Jan Goyvaerts – Steven Levithan
زبان: English
فرمت کتاب: pdf (قابل تبدیل به سایر فرمت ها)
سال انتشار: 2009
تعداد صفحه: 512
حجم کتاب: 6 مگابایت
کد کتاب: 0596520689 , 9780596520687
نوبت چاپ: 1st ed
توضیحات کتاب کتاب آشپزی عبارات منظم
این کتاب آشپزی O’Reilly بیش از صد دستور غذا را ارائه می دهد تا به برنامه نویسان کمک کند تا از عبارات منظم برای دستکاری متن و خرد کردن داده ها استفاده کنند. هر برنامه نویسی به درک عبارات منظم نیاز دارد، اما قدرت آنها بدون مشکل به دست نمی آید – حتی کاربران باتجربه نیز اغلب در حل مشکلات عملکرد مشکل دارند. این کتاب با دستور العمل هایی برای زبان های برنامه نویسی محبوب مانند سی شارپ، جاوا، جاوا اسکریپت، پرل، پی اچ پی، پایتون، روبی و VB.NET، راه حل های گام به گامی را برای تعداد زیادی از وظایف رایج شامل عبارات منظم ارائه می دهد. این کتاب آشپزی به شما کمک می کند:
- اصول عبارات منظم را از طریق یک آموزش مختصر درک کنید
- از عبارات منظم به طور موثر در چندین زبان برنامه نویسی و برنامه نویسی استفاده کنید
- چگونه اعتبار سنجی را بیاموزید و فرمت ورودی
- مدیریت کلمات، خطوط، کاراکترهای خاص و مقادیر عددی
- پیدا کردن راه حل برای استفاده از عبارات منظم در URL ها، مسیرها، نشانه گذاری، و تبادل داده
- تفاوت های ظریف ویژگی های regex پیشرفته تر را بیاموزید
- درک کنید که چگونه API های عبارت منظم از زبانی به زبان دیگر متفاوت هستند
- برای نیازهای سفارشی عبارات منظم بهتری بنویسید
چه یک کاربر تازه کار یا یک کاربر با تجربه، کتاب آشپزی عبارات منظم به درک عمیق شما از این ابزار کمک می کند. با این کتابخانه عظیم از راه حل های اثبات شده برای مشکلات دشوار دنیای واقعی، ترفندهای جدید قدرتمندی را یاد خواهید گرفت، از گوچاهای خاص زبان خودداری کنید و در زمان ارزشمند خود صرفه جویی کنید.
Amazon.com. مرور
چه یک کاربر تازه کار یا یک کاربر با تجربه باشید، Regular Expressions Cookbook به تعمیق درک شما از این ابزار کمک می کند. با این کتابخانه عظیم راه حل های اثبات شده برای مشکلات سخت و دنیای واقعی، ترفندهای جدید قدرتمندی را یاد خواهید گرفت، از گچ های خاص زبان خودداری کنید و در زمان ارزشمند خود صرفه جویی کنید.
جستجو و جایگزینی با عبارات منظم
جستجو و جایگزینی یک کار رایج برای عبارات منظم است. یک تابع جستجو و جایگزینی یک رشته موضوع، یک عبارت منظم و یک رشته جایگزین را به عنوان ورودی می گیرد. خروجی رشته موضوعی است که تمام مطابقت های عبارت منظم با متن جایگزین جایگزین شده است. اگرچه متن جایگزین اصلاً یک عبارت منظم نیست، میتوانید از نحو خاص خاصی برای ساخت متنهای جایگزین پویا استفاده کنید. همه طعمها به شما امکان میدهند متنی را که با عبارت معمولی یا یک گروه عکسبرداری مطابقت دارد، دوباره در جایگزین قرار دهید. دستور العمل های 2.20 و 2.21 این را توضیح می دهند. همانطور که دستور 2.22 نشان می دهد، برخی از طعم ها همچنین از درج متن منطبق در متن جایگزین پشتیبانی می کنند. در فصل 3، دستور العمل 3.16 به شما می آموزد که چگونه یک متن جایگزین متفاوت برای هر تطابق در کد ایجاد کنید.
چندین طعم متن جایگزین
ایده های مختلف توسط توسعه دهندگان نرم افزارهای بیان منظم مختلف منجر به ایجاد طیف گسترده ای از طعم های بیان منظم، هر کدام با نحو و مجموعه ویژگی های مختلف. داستان متن جایگزین هم فرقی نمی کند. در واقع، طعمهای متن جایگزین بیشتر از طعمهای بیان معمولی وجود دارد. ساختن یک موتور بیان منظم مشکل است. اکثر برنامه نویسان ترجیح می دهند از یک موجود استفاده مجدد کنند، و پیچ کردن یک تابع جستجو و جایگزینی بر روی یک موتور عبارت معمولی موجود بسیار آسان است. نتیجه این است که بسیاری از طعمهای متن جایگزین برای کتابخانههای عبارت معمولی وجود دارد که ویژگیهای جستجو و جایگزینی داخلی ندارند.
خوشبختانه، همه طعمهای بیان منظم در این کتاب دارای طعمهای متن جایگزین متناظر هستند، به جز PCRE. این شکاف در PCRE زندگی برنامه نویسانی را که از طعم های مبتنی بر آن استفاده می کنند، پیچیده می کند. کتابخانه منبع باز PCRE هیچ عملکردی برای جایگزینی ندارد. بنابراین، همه برنامهها و زبانهای برنامهنویسی که مبتنی بر PCRE هستند باید عملکرد جستجو و جایگزینی خود را ارائه دهند. اکثر برنامه نویسان سعی می کنند از نحو موجود کپی کنند، اما هرگز این کار را دقیقاً به همان روش انجام نمی دهند.
این کتاب طعم های متن جایگزین زیر را پوشش می دهد. برای جزئیات بیشتر در مورد طعمهای عبارات منظم که با طعمهای متن جایگزین مطابقت دارند، به «بسیاری از طعمهای عبارات منظم» در صفحه 2 مراجعه کنید:
Perl
Perl دارای پشتیبانی داخلی برای جایگزینی عبارت منظم است. از طریق اپراتور s/regex/place/. طعم متن جایگزین پرل با طعم عبارت منظم پرل مطابقت دارد. این کتاب Perl 5.6 تا Perl 5.10 را پوشش می دهد. نسخه دوم پشتیبانی از ارجاعهای پشتی نامگذاری شده را در متن جایگزین اضافه میکند، زیرا ضبط نامگذاری شده را به نحو عبارت منظم اضافه میکند.
PHP
در این کتاب، طعم متن جایگزین PHP به تابع preg_replace در PHP اشاره دارد. این تابع از طعم بیان منظم PCRE و طعم متن جایگزین PHP استفاده می کند.
سایر زبان های برنامه نویسی که از PCRE استفاده می کنند از همان طعم متن جایگزین مانند PHP استفاده نمی کنند. بسته به اینکه طراحان زبان برنامه نویسی شما از کجا الهام گرفته اند، t
- Understand the basics of regular expressions through a concise tutorial
- Use regular expressions effectively in several programming and scripting languages
- Learn how to validate and format input
- Manage words, lines, special characters, and numerical values
- Find solutions for using regular expressions in URLs, paths, markup, and data exchange
- Learn the nuances of more advanced regex features
- Understand how regular expression APIs differ from language to language
- Write better regular expressions for custom needs
Whether you’re a novice or an experienced user, Regular Expressions Cookbook will help deepen your understanding of this tool. You’ll learn powerful new tricks, avoid language-specific gotchas, and save valuable time with this huge library of proven solutions to difficult, real-world problems.
Amazon.com Review
Whether you’re a novice or an experienced user, Regular Expressions Cookbook will help deepen your understanding of the tool. You’ll learn powerful new tricks, avoid language-specific gotchas, and save valuable time with this huge library of proven solutions to difficult, real-world problems.
Searching and Replacing with Regular Expressions
Search-and-replace is a common job for regular expressions. A search-and-replace function takes a subject string, a regular expression, and a replacement string as input. The output is the subject string with all matches of the regular expression replaced with the replacement text. Although the replacement text is not a regular expression at all, you can use certain special syntax to build dynamic replacement texts. All flavors let you reinsert the text matched by the regular expression or a capturing group into the replacement. Recipes 2.20 and 2.21 explain this. Some flavors also support inserting matched context into the replacement text, as Recipe 2.22 shows. In Chapter 3, Recipe 3.16 teaches you how to generate a different replacement text for each match in code.
Many Flavors of Replacement Text
Different ideas by different regular expression software developers have led to a wide range of regular expression flavors, each with different syntax and feature sets. The story for the replacement text is no different. In fact, there are even more replacement text flavors than regular expression flavors. Building a regular expression engine is difficult. Most programmers prefer to reuse an existing one, and bolting a search-and-replace function onto an existing regular expression engine is quite easy. The result is that there are many replacement text flavors for regular expression libraries that do not have built-in search-and-replace features.
Fortunately, all the regular expression flavors in this book have corresponding replacement text flavors, except PCRE. This gap in PCRE complicates life for programmers who use flavors based on it. The open source PCRE library does not include any functions to make replacements. Thus, all applications and programming languages that are based on PCRE need to provide their own search-and-replace function. Most programmers try to copy existing syntax, but never do so in exactly the same way.
This book covers the following replacement text flavors. Refer to “Many Flavors of Regular Expressions” on page 2 for more details on the regular expression flavors that correspond with the replacement text flavors:
Perl
Perl has built-in support for regular expression substitution via the s/regex/ replace/ operator. The Perl replacement text flavor corresponds with the Perl regular expression flavor. This book covers Perl 5.6 to Perl 5.10. The latter version adds support for named backreferences in the replacement text, as it adds named capture to the regular expression syntax.
PHP
In this book, the PHP replacement text flavor refers to the preg_replace function in PHP. This function uses the PCRE regular expression flavor and the PHP replacement text flavor.
Other programming languages that use PCRE do not use the same replacement text flavor as PHP. Depending on where the designers of your programming language got their inspiration, the replacement text syntax may be similar to PHP or any of the other replacement text flavors in this book. PHP also has an ereg_replace function. This function uses a different regular expression flavor (POSIX ERE), and a different replacement text flavor, too. PHP’s ereg functions are not discussed in this book.
.NET
The System.Text.RegularExpressions package provides various searchand- replace functions. The .NET replacement text flavor corresponds with the .NET regular expression flavor. All versions of .NET use the same replacement text flavor. The new regular expression features in .NET 2.0 do not affect the replacement text syntax.
Java
The java.util.regex package has built-in search-and-replace functions. This book covers Java 4, 5, and 6. All use the same replacement text syntax.
JavaScript
In this book, we use the term JavaScript to indicate both the replacement text flavor and the regular expression flavor defined in Edition 3 of the ECMA-262 standard.
Python
Python’s re module provides a sub function to search-and-replace. The Python replacement text flavor corresponds with the Python regular expression flavor. This book covers Python 2.4 and 2.5. Python’s regex support has been stable for many years.
Ruby
Ruby’s regular expression support is part of the Ruby language itself, including the search-and-replace function. This book covers Ruby 1.8 and 1.9. A default compilation of Ruby 1.8 uses the regular expression flavor provided directly by the Ruby source code, whereas a default compilation of Ruby 1.9 uses the Oniguruma regular expression library. Ruby 1.8 can be compiled to use Oniguruma, and Ruby 1.9 can be compiled to use the older Ruby regex flavor. In this book, we denote the native Ruby flavor as Ruby 1.8, and the Oniguruma flavor as Ruby 1.9. The replacement text syntax for Ruby 1.8 and 1.9 is the same, except that Ruby 1.9 adds support for named backreferences in the replacement text. Named capture is a new feature in Ruby 1.9 regular expressions.
دانلود کتاب «کتاب آشپزی عبارات منظم»

📖 خرید این کتاب
برای دریافت فایل و اطلاع از قیمت، روی یکی از دکمههای زیر کلیک کنید تا پیام آماده برای شما ارسال شود:
پس از ارسال پیام، قیمت و لینک دریافت فایل در اسرع وقت برای شما ارسال خواهد شد.