Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex Question 1

Status
Not open for further replies.

tbohon

Programmer
Apr 20, 2000
293
US
I have a file which, besides the 'normal' <cr> characters at the end of each record, also contains some unwanted <cr> embedded in some (not all) of the messages. The only way I can identify these is that they occur after a <BR>, i.e.,

Code:
<BR>^M

where the ^M is how the <cr> appears in the vi editor.

Also, if the <cr> isn't immediately after the <BR> character, it's valid (so they tell me :))

Since I'm nowhere near to being a regex expert, can someone get me started on filtering these out of the file? As it stands, the file causes serious indigestion when it is imported into the receiving application. The idea is to pass the file (multiple records) through a filter, remove these extraneous <cr> characters, and create a new, cleaned up version of the file for transmission.

As always, thanks in advance.

Tom

"My mind is like a steel whatchamacallit ...
 
Perhaps this ?
awk '{x=$0;gsub(/<BR>\r/,"<BR>",x);print x}' /path/to/input > output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the assist. I'm still waiting to see if these extraneous crs can be deleted when the file is generated - if not, I'll use this and see what I can do.

Appreciate it!

"My mind is like a steel whatchamacallit ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top