begin quoting Ralph Shumaker as of Thu, Feb 01, 2007 at 09:59:22PM -0800:
[snip]
> How would I search for every numerical sequence *not* followed by a
> space, and append a space after each such instance?
In vi(m):
:%s/\([0-9][0-9]*\)\([^ 0-9]\)/\1 \2/g
: -> command mode
% -> for every line in the file
s -> substitute
/ -> use / for delimiter
\( -> start first group
[0-9] -> any digit
[0-9] -> any digit
* -> 0 or more of previous character
(This gives the effect of [0-9]+)
\) -> end first group
\( -> start second group
[^ 0-9] -> every character except space and digits (and newlines)
\) -> end second group
/ -> end "find" part, start "replace" part
\1 -> first group
\2 -> second group
/ -> end pattern
g -> global, that is, replace all matches, not just the first on
each line
The key is the [^ ] construct. [0-9] says "match any characters
zero through nine", while [^0-9] says "match any characters NOT
0-9 or newline" (since vi(m) is basically line-oriented).
--
Yeah, so it's not taking advantage of the latest features. So what?
Stewart Stremler
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list