Trying to write a grep style applescript

Whenever I try and compile a grep style script it either performs the code IE puts a hard return in the script or tells me unknown token meaning it is reading the \ between the quotes as a return. What can be done? i am sure there is an easy fix and I think scripting grep styles could be huge.

tell application “Adobe InDesign CS4”

set find grep preferences to nothing

set change grep preferences to nothing

--Search the document for the string "\r\s*$".

set find what of find grep preferences to "\r\s*$" as string

--Replace the search with blank

set change to of change grep preferences to " "

-- this is the actual search and replace command
set myFoundItems to change text

end tell

You have to escape the backslashes with another backslash.