I am also new to regular expressions and I am learning to some basic regular expression rules so I am trying to put them here in new post. Please put your comments if I am doing some mistake while explaining.
There are some special characters which are used while developing the regular expression.Here are some ..
Modifiers
Modifiers are used to alters the meaning of the immediately preceding pattern character.
+ : matches 1 or more of the preceding term
a* matches a,aa,aaa n so on
-----------------------------------------------------------------------------
* : matches 0 or more of the preceding term
a* matches '',a,aa,aaa n so on
-----------------------------------------------------------------------------
? : matches 0 or 1 of the preceding term
a* matches '' n a -----------------------------------------------------------------------------
Literal Characters
. : Matches any character including new line.Its called as wildcard.
Example 'a.c' will match 'aec', 'acc', 'a@a' and so on
-----------------------------------------------------------------------------
[ : Set of characters enclosed in [] matches any of the character included in set.
e.g.REGEX [abc] matches with a or b or c
Inclusive Range[a-d]:matches any characters included in range of a - d.
-----------------------------------------------------------------------------
^ : exclusion range[^a-d]:matches the characters not included in range a-d.
The caret loses its special meaning if it is not the first character of the
set.
It marks as start of line so regex "^start" will match any string that starts with "start".
-----------------------------------------------------------------------------
$ : It marks as end of line so regex "end$" will match any string that ends with "end".
-----------------------------------------------------------------------------
()| : Used for grouping of regular expressions.
(REGX1 | REGX2) will match for either REGX1 or REGX2.
-----------------------------------------------------------------------------
{ : Lets take an example : {1,2} matches between 1 and 2 occurrences of the
preceding term. 't{1,3}' will match 't', 'tt' and 'ttt' only.
Whereas
't{2}' will match 'tt' only.
-----------------------------------------------------------------------------
\ : to escape the special character.
-----------------------------------------------------------------------------
regular expression tutorial basic rules beginners
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment
Post your helpful suggestions on this...