newbio has asked for the wisdom of the Perl Monks concerning the following question:
Example:
Input: **Type_1_deiodinase** , **D1** , metabolizes different forms, **A** , **B** of thyroid hormones to control levels of T3 , the active ligand for **thyroid_hormone_receptors** , **TR**
Output: **Type_1_deiodinase_(D1)** metabolizes different forms, **A_(B)** of thyroid hormones to control levels of T3 , the active ligand for **thyroid_hormone_receptors_(TR)**
If I do the following: $line =~ s/\*\*([^\*]+)\*\*\s\,\s\*\*([^\*]+)\*\*(\s\,)?/**$1_($2)**/g;
it merges all $1 and $2 in the sentence. However, I want to merge terms only if either of $1 or $2 contains '_'.
That is in the above sentence, **Type_1_deiodinase_(D1)** and **thyroid_hormone_receptors_(TR)** are OK, while **A_(B)** is not. Is there a way to apply 'if' condition in the substitution expression above so that I can merge only those adjacent terms that contain '_'?
Thanks a lot.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: conditional statement in substitution expression
by Roy Johnson (Monsignor) on Aug 04, 2009 at 17:16 UTC | |
Re: conditional statement in substitution expression
by jethro (Monsignor) on Aug 04, 2009 at 16:52 UTC | |
Re: conditional statement in substitution expression
by jwkrahn (Monsignor) on Aug 04, 2009 at 17:04 UTC |