Regular expressions are truly powerful, they are used for pattern matching. Let me try to express how powerful I think they are, search is one of the most basic things that most things are based off...what ever we do, we search (I believe thats why Google's so popular
Hopefully, I was able to express how much we do searches (which is based of pattern matching ~ exact match to the search term or approximate match), and how much we rely on pattern matching. This pattern matching can be done in computers using Regular Expressions!!
Getting to the actual point of this post, I decided I will list some useful tips and hints that I found from scouring the internet
(This is related to Linux in that, grep is used for searches using regex in Linux)
Sources:
http://www.regular-expressions.info/characters.html
* Regex engines are case sensitive by default, so "cat" won't match "Cat"
* "at" matches "at","cat","atwood" etc
* The following are metacharacters: [,\,^,$,.,|,?,*,+,(,) - this would change based on the engine
* To use any of these characters literally in a string you would have to escape it using a '\', so in order to use * as an actual character rather than a metacharacter in that search, you would use \* instead
* A character following a '\' can possibly have a special meaning, i.e. \d is used to represent a digit between 0 and 9 - meaning you can't 'escape' normal characters like you do for the metacharacters
Here is a list of special sequences:
* \t = tab
* \r = carriage return
* \n = line feed
CHARACTER CLASS
* [ae] matched a or e NOT ae, example gr[ae]y matches grey and gray not graey
* Ranges can be specified using a '-', so [0-9a-fA-F] specifies 1 character (hexadecimal digit, case-insensitive)
* q[^u] matches anything that has a q followed by something not a u
to be continued...
[ add comment ] | [ 0 trackbacks ] | permalink |




( 2.5 / 25 )
Calendar



