Learn Regex the easy way
Translations: English
中文版
日本語
What is Regular Expression?
Regular expression is a group of characters or symbols which is used to find a specific pattern from a text.
A regular expression is a pattern that is matched against a subject string from left to right. The word "Regular expression" is a mouthful, you will usually find the term abbreviated as "regex" or "regexp". Regular expression is used for replacing a text within a string, validating form, extract a substring from a string based upon a pattern match, and so much more.
Imagine you are writing an application and you want to set the rules for when a user chooses their username. We want to allow the username to contain letters, numbers, underscores and hyphens. We also want to limit the number of characters in username so it does not look ugly. We use the following regular expression to validate a username:
Above regular expression can accept the strings john_doe, jo-hn_doe and john12_as. It does not match Jo because that string contains uppercase letter and also it is too short.
Table of Contents
Basic Matchers
Meta character
Full stop
Character set
Negated character set
Repetitions
The Star
The
Source: https://managewp.org/articles/15874/learn-regex-the-easy-way
source https://williechiu40.wordpress.com/2017/08/15/learn-regex-the-easy-way/