06-18-2009, 12:48 PM
I have been trying to use a regex to clean the contents of the clipboard. When copy and pasting from Acrobat, the selection many times has a carrige return at the end of each line. Want to strip the carriage returns at the end of the line, but I want to preserve the carriage returns at the beginning and end of the clipboard text
I have tried many of the combinations below. To preserve actual paragraph returns I wanted to convert the double carriage returns with a placeholder, then strip all of the other returns, and then convert the placeholders to single carriage returns.
any guidance appreciated
Jeff
======================================================
ClearOutput
int hwnd=win("Adobe Acrobat")
key Cc
_s.getclip
_s.replacerx("(\x0D\x0A){3,}" "qqqq" 1|2)
_s.replacerx("(\x0D\x0A){3,}" "$3" 1|2)
_s.replacerx("\x0D\x0A\x0D\x0A.*")
_s.replacerx("(\x0D\x0A){1,}" "qqqq" 1|2)
_s.replacerx("(\x0D\x0A){1,}" "" 1|2)
_s.replacerx("\x0D\x0A*")
_s.replacerx("(qqqq)""(\r\n)")
_s.setclip()
out _s
I have tried many of the combinations below. To preserve actual paragraph returns I wanted to convert the double carriage returns with a placeholder, then strip all of the other returns, and then convert the placeholders to single carriage returns.
any guidance appreciated
Jeff
======================================================
ClearOutput
int hwnd=win("Adobe Acrobat")
key Cc
_s.getclip
_s.replacerx("(\x0D\x0A){3,}" "qqqq" 1|2)
_s.replacerx("(\x0D\x0A){3,}" "$3" 1|2)
_s.replacerx("\x0D\x0A\x0D\x0A.*")
_s.replacerx("(\x0D\x0A){1,}" "qqqq" 1|2)
_s.replacerx("(\x0D\x0A){1,}" "" 1|2)
_s.replacerx("\x0D\x0A*")
_s.replacerx("(qqqq)""(\r\n)")
_s.setclip()
out _s