[NBLUG/talk] Replacement Syntax in Emacs search/replace string
Dave Sisley
dsisley at sonic.net
Tue Dec 12 12:57:41 PST 2006
Peter Lutz wrote:
> Good Morning.
> I have the following piece of weather data I picked up from a web page.
> As you may be able to see, it's all one line.
> (It's rainfall data for my weather database)
>
> :NAPA COUNTY <br> YOUC1 : MT VEEDER #2251 :
> 0.04/ 0.08/ 0.12/ 0.31/ 1.30/ 1.34<br> YNTC1 : REDWOOD-MT
> VEEDER #2253 : + / + / + / + / + / + <br> NAAC1 :
> NAPA-LINCOLN BRIDG #2260 : 0.00/ 0.04/ 0.04/ 0.28/ 0.87/
> 0.87<br> MSHC1 : MT SAINT HELENA #2277 : 0.00/ 0.04/ 0.04/
> 0.20/ 1.25/ 1.52<br> PFRC1 : PETRIFIED FOREST #2279 : 0.00/
> 0.00/ 0.04/ 0.04/ 1.10/ 1.26<br> DCFC1 : DRY CREEK FIRE STN
> #2281 : 0.08/ 0.08/ 0.12/ 0.24/ 1.10/ 1.14<br> MGTC1 : MT
> GEORGE #2283 : 0.00/ 0.00/ 0.00/ 0.20/ 0.67/ 0.71<br>
> NRXC1 : NAPA-YNTVILLE X RD #2294 : 0.04/ 0.08/ 0.08/ 0.20/
> 0.87/ 0.87<br> SPHC1 : ST HELENA-SULPHUR #2303 : 0.00/ 0.00/
> 0.04/ 0.08/ 1.26/ 1.34<br> HCRC1 : HOPPER CK-HWY 29 #2313 :
> 0.04/ 0.08/ 0.08/ 0.24/ 0.98/ 0.98<br> SUGC1 : SUGARLOAF
> PEAK #2324 : 0.00/ 0.04/ 0.08/ 0.20/ 0.63/ 0.63<br> MLDC1
> : MILLIKEN DAM #2329 : 0.00/ 0.00/ 0.00/ 0.00/ 0.00/
> 0.00<br> STHC1 : ST HELENA 4WSW #7005 : + / + / + /
> + / + / + <br> ANGC1 : ANGWIN #7014 : + / +
> / + / + / + / + <br> NAPC1 : ATLAS PEAK #7015 :
> 0.08/ 0.08/ 0.08/ 0.32/ 1.20/ 1.20<br> <br>
>
> I would like to replace all the <br> with a new line character in
> Emacs, but I
> can't find out how to specify the new line as the replacement
> character. I've
> tried \n, \\n, \\\n, ^M, ^Q^M but none of these work.
>
> Any help please?
>
Peter:
The other suggestions so far are good, but one way to do this without
leaving emacs is to:
- yank an actual hard return
- use the emacs search and replace (esc, %)
- replace <br> with the yanked hard return (just hit ctrl-y when it asks
you "Query replace <br> with:"
- press the ! key
... and presto!
:NAPA COUNTY
YOUC1 : MT VEEDER #2251 : 0.04/ 0.08/ 0.12/ 0.31/ 1.30/
1.34
YNTC1 : REDWOOD-MT VEEDER #2253 : + / + / + / + / +
/ +
NAAC1 : NAPA-LINCOLN BRIDG #2260 : 0.00/ 0.04/ 0.04/ 0.28/
0.87/ 0.87
MSHC1 : MT SAINT HELENA #2277 : 0.00/ 0.04/ 0.04/ 0.20/
1.25/ 1.52
PFRC1 : PETRIFIED FOREST #2279 : 0.00/ 0.00/ 0.04/ 0.04/
1.10/ 1.26
DCFC1 : DRY CREEK FIRE STN #2281 : 0.08/ 0.08/ 0.12/ 0.24/ 1.10/
1.14
MGTC1 : MT GEORGE #2283 : 0.00/ 0.00/ 0.00/ 0.20/ 0.67/
0.71
NRXC1 : NAPA-YNTVILLE X RD #2294 : 0.04/ 0.08/ 0.08/ 0.20/
0.87/ 0.87
SPHC1 : ST HELENA-SULPHUR #2303 : 0.00/ 0.00/ 0.04/ 0.08/
1.26/ 1.34
HCRC1 : HOPPER CK-HWY 29 #2313 : 0.04/ 0.08/ 0.08/ 0.24/
0.98/ 0.98
SUGC1 : SUGARLOAF PEAK #2324 : 0.00/ 0.04/ 0.08/ 0.20/
0.63/ 0.63
MLDC1 : MILLIKEN DAM #2329 : 0.00/ 0.00/ 0.00/ 0.00/ 0.00/
0.00
STHC1 : ST HELENA 4WSW #7005 : + / + / + / + / + / +
ANGC1 : ANGWIN #7014 : + / + / + / + / +
/ +
NAPC1 : ATLAS PEAK #7015 : 0.08/ 0.08/ 0.08/ 0.32/ 1.20/ 1.20
<smiley>
-dave.
More information about the talk
mailing list