anotherJEK
01-06-2012, 10:27 PM
I have a situation where there is a string:
m0|18:+:m1|(-3)
which is a tracking method for preserving memory references
in the following string:
18+(-3)
In the user interface of the project I am working on; the user
changes the string to:
(18+(-3))*8
The object is to revise the memory tracking string to repersent
the changes. should be: (m0|18+m1|(-3))*8
//matches = this.getMemVals()
// getMemVals() searches the string 'm0|18:+:m1|(-3)'
// with regex pattern to find instances of m#|#
var matches = new Array()
matches[0] = 'm0|18';
matches[1] = 'm1|(-3)';
var currentStateSaved = '(18+(-3))*8';
var glbs = '';
for(i = 0; i < matches.length; i++)
{
var matRegex = new RegExp(matches[i].substring(matches[i].indexOf('|')+1), 'g');
alert('matReg: '+matRegex);
glbs = currentStateSaved.replace(matRegex, matches[i]);
}
alert('GLBS: '+glbs) // <<< test code
The '18' part of m0|18 is not be found in the revised literal string
Why? (Has '18' been coverted to a number datatype?)
This is the type of problem that drives me up a wall and cost far to
much time trying to flush it out
Thanks of suggestions, advice
JK
m0|18:+:m1|(-3)
which is a tracking method for preserving memory references
in the following string:
18+(-3)
In the user interface of the project I am working on; the user
changes the string to:
(18+(-3))*8
The object is to revise the memory tracking string to repersent
the changes. should be: (m0|18+m1|(-3))*8
//matches = this.getMemVals()
// getMemVals() searches the string 'm0|18:+:m1|(-3)'
// with regex pattern to find instances of m#|#
var matches = new Array()
matches[0] = 'm0|18';
matches[1] = 'm1|(-3)';
var currentStateSaved = '(18+(-3))*8';
var glbs = '';
for(i = 0; i < matches.length; i++)
{
var matRegex = new RegExp(matches[i].substring(matches[i].indexOf('|')+1), 'g');
alert('matReg: '+matRegex);
glbs = currentStateSaved.replace(matRegex, matches[i]);
}
alert('GLBS: '+glbs) // <<< test code
The '18' part of m0|18 is not be found in the revised literal string
Why? (Has '18' been coverted to a number datatype?)
This is the type of problem that drives me up a wall and cost far to
much time trying to flush it out
Thanks of suggestions, advice
JK