Top add

Learning Regular Expression - Part 1

Regular expression is an expression by which searching of codes is made simpler it is defined by American mathematician Stephen Kleene

Regular expression has this below 4 parts in it
Literal Character we use in search
Metacharacter Special character that we use in regular expression eg: $ ^
Escape string A way of indicating the user of metacharacter
Search expression Search string that we use to search target string

Symbols in meta characters
Brackets []Matching of single characters or multiple characters in the stiring
-Range Operators ex : a-z (lower case from a to z)
^ Expect or not operator ex : [^aA] any character not a and A
$ Will look only at the end of string
. Will replace any character on . ex .in matches windows, linux
? Matches preceding characters only once.
* Matches preceding characters multiple times
| also called alternation matches left or right side characters ex : gr(a|e)y matches grey and gray

Examples:
[^0-9] Any character other than a number
[0-9]] Any number followed by a "]"
[0-9\-a\]] Any number, or a "-", a "a", or a "]"
^AA* Any line if it starts with one "A"

No comments: