Ralph Shumaker wrote:
Ralph Shumaker wrote:
Stewart Stremler wrote:
begin quoting John H. Robinson, IV as of Fri, Feb 02, 2007 at
09:38:56AM -0800:
Ralph Shumaker wrote:
Ralph Shumaker wrote:
Examples:
^9And ...
^10 For ...
Needed to be:
^9 And ...
^10 For ...
If I had thought about regexen _before_ I did any insertions of a
space between the numeric and the alpha, then I wouldn't even have
needed to qualify the alpha,
Except - you would have ended up with:
^9 And ...
^10 For ...
Note the double space before the For. You were very correct in
specifying that the alpha had to be right next to the numeric.
IIRC, he did string-substitution to insert that space. He came to
the list to take care of the tedious and boring problem after he'd
started. (Right, Ralph?)
Right you are, Stewart.
Also, \d and \w are Perl Compatilble Regular Expression (PCRE)
syntaxes.
My testing shows they don't work in vi(m).
In vi, I you can use [:digit:], but [0-9] is shorter and backwards
compatible to vi. Likewise [:space:].
If this was going to be more than a once-off change, then I'm bang
behind perl (or sed) for automating this.
Agreed. I got my feet wet in Perl a long time ago. I remember just
enough that I wouldn't be totally lost if I were to wade in again.
Now I want to do a search an replace (with verification) of something
involving mixed case. I tried to figure out the formula, but I'm
hitting a catch-22 with my limited knowledge.
Let's say I want to replace a whole bunch of "the" and "The" with
"this" and "This" respectively. And I need to make sure that "the"
and "The" are not preceded nor followed by alpha. How would I do
this? Oh, and how can I make it so that the highlighted match is
always vertically centered (so I can see context)?
("the" and "The" are not the only sets I want to replace with others,
so I really would like to know a formula. Or am I just better off
doing the replace twice? once for lowercase and again for upper?)
I think I just figured it out:
":%s/\([^A-Za-z][Tt]h\)e\([^A-Za-z]\)/\1is\2/c
The trick to getting it was to realize that the set \(\) is not actually
part of the search but only like an embedded copy function with \1 and
\2 being the embedded paste function.
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list