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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex help

Status
Not open for further replies.

cginewbie

Programmer
Jan 20, 2002
24
US
I have a problem
I have some $INPUT{input1}, $INPUT{name2}, , ....$INPUT{whatver}
in a file, and I want to change them all in one line
so that every $INPUT{inputX} will have the value of $OUTPUT{inputX}

I do something like
$file =~ s/$INPUT{(.)+}/$OUTPUT{1}/g;
but it does not work?

thanks
 
Can you rephrase that? I didnt understand correctly ..


wzrd
 
hi,
The problem is, I have a file that has hash variables in it (i.c %INPUT). After I read the file into an array, and I want the values of the harsh (%INPUT) to kick in. Since The file exist after the harsh has been defined, so the values of the harsh in the string won't change.

My question is that how do I do change every harsh values in regex... I can do in multiple regex's like this

$string =~ s/\$INPUT{name}/$INPUT{name}/g;
$string =~ s/\$INPUT{address}/$INPUT{address}/g;
...
But i think there should a way to make it in one regex, but just dont know how..
I have tried
$string =~ s/\$INPUT{(.)+}/$INPUT{$1}/g;
but it won't work
 
Try putting the + inside the brackets of your $1 variable. Your $1 is only going to hold one character.

greadey.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top