not sure if this is the correct place to ask since its more of a PHP problem than drupal's

Steps
1) fetch node's taxonomy terms
ie term names: book 1, book 1:1, book 1:2 , book 1:3 , book 2 , book 3

$terms = taxonomy_node_get_terms($node);
foreach($terms as $term){
//do somehting
}

2)use regex to match and change it into something like this
book 1-2, book 1-3, book 2-3 , book 1:1-2 , book 1:2-3 , book 1:1-3

any idea on how to do step2 ?

*usage for this - to allow use to search a range of taxonomy terms ie : search book 1-3 , returns all nodes related to book 1, book 2 , book 3

CCK computed_field provides generates the text to be indexed
and
field indexer indexes them to be search as text.