Removing line endings on selected text

Hello everyone,
I modified a simple script to tailor my needs. The script at the moment copies a selected text and creates a new rtf file with the selection. I would like to remove line endings and replace hyphens as the text is always grabbed from OCR’d images. Could anyone point me on how to do it? Many thanks

tell application id "com.devon-technologies.thinkpro2"
		if not (exists think window 1) then error "No window is open."
		if not (exists content record) then error "Please open a document."
		set theText to selected text of think window 1 as string
		if theText is missing value or theText is "" then error "No text is selected."
		display dialog "name:" default answer "" buttons {"Cancel", "OK"} default button 2
		set prefix to the text returned of the result
		set theSelection to the selection
		set theRecord to item 1 of theSelection
		if exists parent 1 of theRecord then
			create record with {name:prefix, type:«constant Etyprtf », rich text:theText} in parent 1 of theRecord
			create record with {name:prefix, type:«constant Etyprtf », rich text:theText}
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

My preference is to pass the text chunk to Ruby and use the Regex facilties there to do the conversions. Of course, you could use a variety of other languages: Python, Perl, etc.

If you need an example, I could dig around and post something…

Best, Charles