

Task

   match a string against a regular expression
   substitute part of a string using a regular expression


 
set text to "This is a story about R2D2 and C3P0 who are best friends."
set pattern to <word start, letter, digit, letter, digit, word end>
 
put the sixth word of text matches pattern -- (note: the sixth word is "R2D2")
 
put every occurrence of pattern in text
 
replace the second occurrence of pattern in text with "Luke"
put text
 