Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression matching variable name

Status
Not open for further replies.

jerijeri

Programmer
Sep 11, 2002
33
CA
Help,

I'd like to replace all merge fields with a corresponding variable.

Currently we have one line
s/\\!(\$[\w\[\]\{\}\'\"]*)\\/$1/eeg;

handling all the replacements.

example we have
\!$FORM{Text1}
to

\!$FORM{Text20}
and $Text1 to $Text20 are replaced.

We'd like to change the style

\!$FORM{Variable_Name}\ to yyVariable_Nameyy

yyOWNERyy would be replaced with value for $OWNER
yyBOATyy would be replaced with $BOAT

I'm just not getting anywhere with the new RegExp. Any help appreciate.

Thanks,

Jer

 
what did you try that isn't working?
Here's one option.
Code:
s/yy(.*?)yy/${$1}/g;
if that's off the mark then you'll have to better describe what your data looks like.

jaa
 
Well I what I had was close to what you answered. Your solution was the correct answer to the question I asked, unfortunately I discovered my thinking was flawed.

What I needed to do was the following:

s/yy(.*?)yy/${\$FORM{$1}}/g;

This will allow the substitutions for any field names we create.

I did discover one problem. With this substitution,

Upper Case J U and Z never appear. Lower case q and z also never appear. Any ideas why?

Thanks,

Jer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top