Regular Expressions and Substitution
Posted on 2004-09-02
I want to take a string that contains multiple form components and replace the name descriptor to be the name followed by an expression. For example, I want to change the following part of every component description:
name='someName' + aNumber
where aNumber is a variable (integer). I want this to work on at least the major browsers.
Two ways I've considered is if there is a way to update the descriptor of a form component or the use of regular expressions. I don't really care how, I just can't seem to resolve the problem. For instance, when using replace, how can I tell it to "append" to the regular expression item that it found?
The key issue I am having is determining a simple way to use the string the regular expression just found. I believe this is the regular expression I want:
/name='\w*'/ but replace only seems to take a specific string as the second argument. Basically I just need to know if there is some reference to the expression I just found. I've tried $0 and $1, both are null.
Thanks for any quick help!
Thanks for any help!