views:

657

answers:

2

This feels like it should be an easy one, but I'm having trouble cleaning out the newline character in content pasted from Microsoft Word. Not a full line-break, but the CTRL ENTER character that shows up as a return arrow in Word. I've tried chr(10), chr(13), \u000D, \u000A and a few others, but I can't match it in a string.replace(). Should I be looking for a different character or do I need to use something other than the string.replace method?

+4  A: 

Run this:

print repr(mystringobject)

That will give a hint of which character you want to remove.

If still no clue, paste the result of the command above in the question, and I'll edit my answer.

nosklo
Thanks to both you and Chris. It was \x0b
Tom
+1  A: 

you can get the ASCII value of the character like this:

for c in 'string':
    print ord(c), hex(ord(c))

once you know the code, it should be easy to kill the offender.

Chris Lawlor