X
X l e c t r i c
Here:
http://bigbangfodder.fileave.com/res/sandr.html
I'm trying to use string.replace() for a basic search and replace form
using textarea values as the regexp and replacement values for
string.replace().
When I tried to use the textarea variable name for regexp it didn't work
as I thought it would. For example:
string.replace(/variablename/, replacementvariablename);
This actually searched for variablename instead of the value it
represents. Which actually makes sense. What I did to solve the problem
was this:
var e_v = eval('/' + variablename + '/' + g_b + c_s);
where g_b and c_s are variable names for global and sensitivity
depending upon whether or not checkboxes are checked.
Then I follow that with:
t_ai.value = t_ai.value.replace(e_v, t_ar);
t_ai is the variable name for the textarea that holds the text that's
being searched and t_ar is the variable name for the replacement
textarea value.
Is there a way that I can accomplish this without using eval() ?
The text in the textareas and the "Clear Values" button are there as a
convenience for anyone who takes a look to help me, and won't be there
when I'm finished.
Art
http://bigbangfodder.fileave.com/res/sandr.html
I'm trying to use string.replace() for a basic search and replace form
using textarea values as the regexp and replacement values for
string.replace().
When I tried to use the textarea variable name for regexp it didn't work
as I thought it would. For example:
string.replace(/variablename/, replacementvariablename);
This actually searched for variablename instead of the value it
represents. Which actually makes sense. What I did to solve the problem
was this:
var e_v = eval('/' + variablename + '/' + g_b + c_s);
where g_b and c_s are variable names for global and sensitivity
depending upon whether or not checkboxes are checked.
Then I follow that with:
t_ai.value = t_ai.value.replace(e_v, t_ar);
t_ai is the variable name for the textarea that holds the text that's
being searched and t_ar is the variable name for the replacement
textarea value.
Is there a way that I can accomplish this without using eval() ?
The text in the textareas and the "Clear Values" button are there as a
convenience for anyone who takes a look to help me, and won't be there
when I'm finished.
Art