Saturday, October 12, 2013

Regular Expressions

Now I'm reading http://www.regular-expressions.info/tutorial.html for making simple log analyzer using python.

I was confused with special characters, which are used in VIM & other applications.

I started to use regular expressions searching for strings in VIM editor, so I got used to the regular expression of VIM. In VIM's regular expressions, if I want to find "+", I have to type just "+". But in python I use "\+" instead of "+" because "+" is registered as a special character(meta-character). (http://docs.python.org/2/library/re.html?highlight=split#re.split)
In VIM "\+" is a meta-character. It is opposite to python.

Special characters are 12: "\, ^, $, ., |, ?, *, +, (, ), [, {, "


No comments: