Reply to message «Re: arithmetic expressions in search», sent 22:33:21 27 April 2011, Wednesday by googler:
> Thanks for the reply. But it may not always be simple like you showed > above. For example, if I wanted to only search for those numbers that > are divisible by 7. If such a feature is currently not available in > vim, it maybe a good idea to add it? Just a suggestion.. Normally you do the following: create a regular expression that is able to find all numbers and then write additional code which will filter the results of the first search so that only numbers divisible by 7 are left. I do not think this should be added to regex engine: most of time such advanced features are not needed and when they are needed they may lead to highly inefficient solution. I saw only one language where you can embed such condition in a regular expression (by embedding a code), but I have never seen any examples of code that uses this feature. (Of course, this language is perl.) Original message: > On Apr 27, 3:36 am, "John Beckett" <[email protected]> wrote: > > googler wrote: > > > I have a file where I have words like X1, X2, ..., X16, X17, X18, .... > > > I want to find out occurences of words containing a number > > > greater than, say, 17. So basically, I want to find X18, X19, > > > X20, etc. How can I do this in vim? In other words, can we > > > use arithmetic expressions in search? If yes, how? > > > > I believe there is no way to search for a number depending on an > > expression. You would have to do it manually, something like > > this simple effort: > > > > /X1[89]\|X[2-9][0-9] > > > > John > > Thanks for the reply. But it may not always be simple like you showed > above. For example, if I wanted to only search for those numbers that > are divisible by 7. If such a feature is currently not available in > vim, it maybe a good idea to add it? Just a suggestion..
signature.asc
Description: This is a digitally signed message part.
