Hi all,
BTW, in my examples below where you see "<" and ">" replace them with the HTML entity when running the scripts, the browser has converted them to the actual character.
Seems like all my issues revovle around mappings and string replacement. aarrghh! Anyhow, I have a string that has an ampersand in it. I tried using regsub and of course if substituted the string but also substitued the ampersand in the string with the original string value, see example:
set termsURL /files/22994_HL&P_Terms_of_Service.pdf
set contentDetails_5 "account(s) or other transactions with Reliant Energy. I
have read and understand the <inserttermshere>. I am at least eighteen yea
rs of age and legally authorized to change REP's for the address(es) listed abov
e.</font></p>"
regsub -all -- {<inserttermshere>} $contentDetails_5 $termsURL contentDetails_5
See the problem? Well, to work around this I wrote this little script to do the replacement instead, just wondering if their was a better way?
set termsURL /files/22994_HL&P_Terms_of_Service.pdf
set contentDetails_5 "account(s) or other transactions with Reliant Energy. I have read and understand the <inserttermshere>. I am at least eighteen years of age and legally authorized to change REP's for the address(es) listed above.</font></p>"
set search_index {0}
set open_terms [string first "<insert" [string tolower [string range $contentDetails_5 $search_index end]]]
set close_terms [string first "here>" [string tolower [string range $contentDetails_5 $search_index end]]]
set current_begin_index [expr $open_terms -1]
set current_close_index [expr $close_terms + 1]
set stringToReplace {}
set stringToReplace "[string range $contentDetails_5 $open_terms [expr $close_terms + 7]]"
set rebuilt_string [string range $contentDetails_5 0 $current_begin_index]
append rebuilt_string $termsURL
append rebuilt_string [string range $contentDetails_5 [expr $current_close_index + 7] end]
set input_string $rebuilt_string
TIA,
Harold
BTW, in my examples below where you see "<" and ">" replace them with the HTML entity when running the scripts, the browser has converted them to the actual character.
Seems like all my issues revovle around mappings and string replacement. aarrghh! Anyhow, I have a string that has an ampersand in it. I tried using regsub and of course if substituted the string but also substitued the ampersand in the string with the original string value, see example:
set termsURL /files/22994_HL&P_Terms_of_Service.pdf
set contentDetails_5 "account(s) or other transactions with Reliant Energy. I
have read and understand the <inserttermshere>. I am at least eighteen yea
rs of age and legally authorized to change REP's for the address(es) listed abov
e.</font></p>"
regsub -all -- {<inserttermshere>} $contentDetails_5 $termsURL contentDetails_5
See the problem? Well, to work around this I wrote this little script to do the replacement instead, just wondering if their was a better way?
set termsURL /files/22994_HL&P_Terms_of_Service.pdf
set contentDetails_5 "account(s) or other transactions with Reliant Energy. I have read and understand the <inserttermshere>. I am at least eighteen years of age and legally authorized to change REP's for the address(es) listed above.</font></p>"
set search_index {0}
set open_terms [string first "<insert" [string tolower [string range $contentDetails_5 $search_index end]]]
set close_terms [string first "here>" [string tolower [string range $contentDetails_5 $search_index end]]]
set current_begin_index [expr $open_terms -1]
set current_close_index [expr $close_terms + 1]
set stringToReplace {}
set stringToReplace "[string range $contentDetails_5 $open_terms [expr $close_terms + 7]]"
set rebuilt_string [string range $contentDetails_5 0 $current_begin_index]
append rebuilt_string $termsURL
append rebuilt_string [string range $contentDetails_5 [expr $current_close_index + 7] end]
set input_string $rebuilt_string
TIA,
Harold