Hi Monks,
What is the scope of the standard RegEx variables like $_, $' etc?
I'm trying to loop through a RegEx with the following code and replace all occurances of 'exhibit' with different verbs so that exhibit is not repeated (eg exhibit, show, reveal, display etc...). I'm using this code, but it crashes with 'variable not initialised' on the line $loc_end_pos = pos($_) - length($1);. I suspect $_ is being reset by __exhibit_verb_function. What do you think?
if (/(\{exhibit\})/) { $loc_exhibit_txt = $loc_observation_model->__exhibit_verb_function +($k-1+$gl_exhibit_verb_marker_idx, $gl_language_country, "G"); $loc_end_pos = pos($_) - length($1); $loc_string_out = $loc_string_out . substr($_,$loc_start_pos,$loc_ +end_pos-$loc_start_pos); # Add variable $loc_string_out = $loc_string_out . $loc_exhibit_txt ; # Ad +d variable $loc_start_pos=pos($_); }
Thanks for your help.
regards
Steve
In reply to Scope of RegEx vars like $_ by Steve_BZ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |