Regular Expression in Vim that will count 1 or colon

I am rather new to using vim with regular expressions and I need to count specific entries in a .csv file The entries are in this form:

9,1,8-Mar-11,high,A2,mid,500,1000,0.143494345,0.153521446,1121.386992,409.6833333,,
9,2,8-Mar-11,high,A2,mid,500,1000,0.180015537,0.256840072,1190.977918,420.8229933,1,
9,3,8-Mar-11,high,A2,mid,500,1000,0.250273568,0.16378268,1061.417761,419.1692065,,1

I need to count the number of 8-Mar-11, A2 conditions which have either ,, or ,1 (,|1) or (,|1),1 on the end of the lines.

here is the regular expression that i use in vim to get some count data:

:%s/.*8-Mar-11.*A2.*,,1$//gn

What I would like to know is there a way to use either in vim? like:

:%s/.*8-Mar-11.*A2.*,1\(,|1\)//gn

Any advice or help is greatly appreciated!

Answers


When you're composing a regular expression which is searching for one character or another, alternation using pipes is overkill. Use a character class instead:

:%s/.*8-Mar-11.*A2.*,1[,1]//gn

VIM regexes are weird and confusing. You have to escape the | as \| for or


Need Your Help

Tinyint used for true/false

php mysql

I created a table person with two tinytint fields to decide the role of a person. The roles are instructor and faculty. A person can be one or both. I preferred to use tinyint since I can possibly ...

google account sync on android 2.2 device

android android-c2dm

I am implementing C2DM for push notification in an android application, it need at least

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.