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!

awking an email - part 3 1

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hallo again...

I 2 previous threads I have successfully manages to rewrite an email body. I have a small problem though. The email is passed to an application that does not allow certain charactes, let's use the '&' as an examle.

I have this:

# Set field-separator.
BEGIN { FS = " *= *" }
# Remove trailing spaces.
{ sub(/[ \t]+$/, "") }
!working && /^$/ { working = 1
print "\n\n<TAG1>
!working { print ; next }
/^phone_number/ { pr(); $0 = "<phone>"$2"</phone>"
print; next}
/^textfield2/ { pr(); accum="<problem_desc>" $2; next}
NF { accum = accum RS $0 }
END { pr(); print "</TAG1>\n" }
function pr()
{ if ( accum ) print accum "</problem_desc>"
accum = ""
}
1

The textfield2 however may contain the & character. Is there a way to search and replace this character (if it is there) with for example the word 'and' ?

 
{gsub(/&/,"and")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sweet, nice and simple. Many thanks, much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top