Tuesday, July 30, 2013

Re: regexp help

On 30.07.13 10:18, RICHARD PITMAN wrote:
> Apologies if this is a re-post, I think the first went to the wrong address...
>
> I have a fortran program in which there are two sorts of numbers,
> integers which are simply digits not followed by a period, and double
> precision numbers in the form 1.0D0, or more precisely \d\+\.\d\+D\d\+
> I would like to search for the former, avoiding the latter.

When I apply this search:

/\v([ \t]|^)[0-9]+\_s

to this line:

123 123.0 123. 456 0.123 .123 789

it stops only at each integer. Is that close enough?
(It includes leading space. But perhaps \@<= could fix that, if it's
important?)

I would have expected

/\v[ \t^][0-9]+\_s

to also match, but '^' isn't working for me as "start of line" in the
character class. (It is only as first character in the class (Vim calls
that a "collection"), that it would negate the class.)

The regex has the benefit of being largely posix, just using vim's \_s
as shorthand for (whitespace or EOL). (Most posix implementations have
extensions, so why shouldn't vim?)

Erik

--
In attempting to ride roughshod over 1170 written objections, a local
government determination, a resident survey 94% against them, and years of
protests, McDonald's is seeking to trash democracy, AFAICT. We do _not_ want
them in our hills! BURGER OFF from Tecoma. See: http://www.burgeroff.org/
and www.change.org

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: