By converting the paragraph to string you are inherently stripping all the formatting data.Instead, you should reference the data as text.Text retains formatting and style data and will do what you want. Replace every instance of 'as string' in your script with 'as text' and you should be set.
Universal Access System Preference pane.
set theReplacements to {¬
{"0mg ", "0 mg "}, ¬
{"5mg ", "5 mg "}, ¬
{" ", " "} ¬
}
tell application "Pages" to activate
tell application "System Events" to tell process "Pages"
keystroke "f" using command down
repeat until exists window "Find & Replace"
end repeat
tell window "Find & Replace"
click radio button "Simple" of tab group 1
repeat with thisReplacement in theReplacements
set {X, Y} to thisReplacement
keystroke X
keystroke tab
keystroke Y
keystroke tab
click button "Replace All" of tab group 1
end repeat
click button 1
end tell
end tell
The script has been tested under OS X 10.8.1.
hadoop training in chennai | informatica training in chennai