Showing posts with label regular expression. Show all posts
Showing posts with label regular expression. Show all posts

Friday, July 3, 2015

Understand Regular Expression

CharacterDescription
\wMatches any word character (alphanumeric).
\WMatches any non-word character.
\sMatches any whitespace character (tab, newline, carriage return, form feed, vertical tab).
\SMatches any non-whitespace character.
\dMatches any numerical digit.
\DMatches any character that is not a number.
[\b]Matches a backspace.
.Matches any character except a newline.
[...]Matches any one character within the brackets.
[^...]Matches any one character not within the brackets.
[x-y]Matches any character in the range of x to y.
[^x-y]Matches any character not in the range of x to y.
{x,y}Matches the previous item at least x times but not to exceed y times.
{x,}Matches the previous item at least x times.
{x}Matches the previous item exactly x times.
?Matches the previous item once or not at all.
+Matches the previous item at least once.
*Matches the previous item any number of times or not at all.
|Matches the expression to the left or the right of the | character.
(...)Group everything inside parentheses into a subpattern.
\xMatches the same characters that resulted from the subpattern in group number x. Groups, which are designated with parentheses, are numbered from left to right.
^Matches the beginning of the string or beginning of a line, in multiline matches.
$Matches the end of the string or end of a line, in multiline matches.
\bMatches the position between a word character and a non-word character.
\BMatches the position that is not between a word character and a non-word character.
Know More in Regular Expression
CharacterDescription
\fForm feed
\nNewline
\rCarriage return
\tTab
\vVertical tab
\/Forward slash (/)
\\Backward slash (\)
\.Period (.)
\*Asterisk (*)
\+Plus (+)
\?Question Mark (?)
\|Horizontal bar (|)
\(Left parenthesis (
\)Right parenthesis )
\[Left bracket ([)
\]Right bracket (])
\{Left curly brace ({)
\}Right curly brace (})
\XXXASCII character represented by the octal number XXX
\xHHASCII character represented by the hexadecimal number HH
\cXThe control character represented by X

Friday, December 12, 2014

Regular Expressions in PHP

Regular Expression
Regex is used to match any pattern against any string
Its use for pattern matching
Its very powerful but use only in extreme case (Increase the lookup time)

wild card -> . $ * ^ + ? |
match scope -> () {} []

regex vs string/array functions ->
preg_match() ->
preg_replace() ->
preg_split() ->
preg_grep() ->

Thursday, December 11, 2014

What i Learn in Notepad++

Replace Duplicate Rows
^(.*?)$\s+?^(?=.*^\1$)

Replace Blank Rows
[\r\n]+

New Rows
\r\n

Replace Content between 2 anchor Tags
</a>.*?<a
</a>\r\n<a

Replace Brakets Inside Content
\{[^{}]*\} replace with space

Insert Something Vertically
ALT+C

Convert to Uppercase
CTRL+SHIFT+U

Resources
http://www.shortcutworld.com/en/win/Notepad-plus-plus_5.9.html
http://letconex.blogspot.in/2013/06/how-to-use-regular-expressions-in.html

http://www.iacquire.com/blog/18-meta-tags-every-webpage-should-have-in-2013

MSWORD Wild Card
http://www.gmayor.com/replace_using_wildcards.htm
http://superuser.com/questions/290618/subscripts-and-superscripts-in-excel

Special Char Codes
http://www.utexas.edu/learn/html/spchar.html