8 Basics of Regular Expressions
Regular expressions have been something that I was scared of when I started coding as a serious stuff. The string literals puzzled me like anything. preg_match, preg_grep, preg_split, preg_replace etc have been something I always wanted to avoid. This is for you guys who find regular expressions tacky.
Searches a string that starts with tech.
Searches for strings that ends up in logy.
Looks for a string that has either zero or more a’s but exactly one b following a. (eg. b, ab, aab, aaab, aaaaaaaaaaaaaaaaab etc.).
Same as a*b but only difference is that atleast one a should be there in the string unlike a*b which can overlook a. (eg. ab, aab,aaaaaaaaab etc).
In this case string might have either zero or a single a (eg. ab or b) only these two possibilities are there.
QUANTIFYING THE CHARACTERS
To quantify the characters into certain sets and utilize them we can use paranthesis().
Matches a string which consists of pattern having abc either one or n times followed by def at the end.
LOGICAL OPERATORS [OR(|) & AND(.)]
A string of a and b that ends in a c.
To specify range of characters. For instance to match that in a password small-case character, you can specify the set as [a-z] or [A-Z] or [0-9].
Searches for a pattern having either small-case or capital letters.