Ralph Shumaker wrote:
Andrew Lentvorski wrote:
Ralph Shumaker wrote:
Examples:
^2And ...
^3This ...
^4And ...
^5Before ...
^6Like ...
^7He ...
^8Open ...
^9And ...
^10 For ...
^11 Certain ...
^2Because ...
^3Open ...
^4Begin ...
.
.
.
Needed to be:
^2 And ...
^3 This ...
^4 And ...
^5 Before ...
^6 Like ...
^7 He ...
^8 Open ...
^9 And ...
^10 For ...
^11 Certain ...
^2 Because ...
^3 Open ...
^4 Begin ...
Okay, given that, couldn't you have used:
\^\d+\s+\w+
\^ escapes the caret
\d+ matches one or more digits [0-9]
\s+ matches one or more whitespace
\w+ matches one or more word characters [0-9A-Za-z_]
Although, you would still have to handle grouping the match for the
replace.
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, if you are saying that \d+ would have matched on any
number of digits. I could have done a replace that changes "\^\d+" to
"\^\d+ " assuming that would not insert spaces between the digits. If I
could have done that, I could have wasted far less time. As it was, I
did (in gedit) a replace of "00" with "00 ", verifying (or skipping)
each one, then with "01", then "02", and so on. It was tedious, but
nowhere near as bad as when I hit the single digits. The "00" through
"09" were all preceded by "^1". The "10" through "99" could have been
preceded by either a "^1" or a "^". But after all that, all that was
left were hundreds of groupings of "^2" through "^9", each immediately
suffixed by a capitalized word. (Later, I found 10 instances where the
"^[2-9]" was immediately suffixed by "(". A slight modification to
Stewart's magic incantation found and fixed them all.)
I spent much more effort than I needed to. But it wasn't until I
started the TEE-DEE-US replacement of the leftovers that I realized that
regex might be the way to go. But this is only because I am unpracticed
in the black art of regex. Had I thought about regex before even
starting to insert spaces, I would have searched for the formula to
search for every numeric sequence and insert a space at the end of each
one. Actually, this would be a good final check.
How would I search for every numerical sequence *not* followed by a
space, and append a space after each such instance?
I figured it out, well, the search part anyway. I did
"/\([0-9][^0123456789 ]\)" which yielded only one match. A solitary
instance of a lower case letter following a number. I manually inserted
the space and converted to uppercase. Now that the easy part is
done..., back to the tedious.
Thanks to all who helped me.
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list