write(sub("((0[^0]|10|11):..)","\\1 AM",sub("(12.+)","\\1 PM",scan("stdin",""))),1)
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page