I spent an hour trying to get this working:
string = "My STRING=15";
regx = new RegExp( "(\d+)", "g" )
//regx = /([A-Z]+)=(\d+)/;
//regx = /(\d+)/g;
//regx = /[\w]+/g
//stringObj = String(string)
//print( stringObj.indexOf( regx ))
print( string.indexOf( regx ))
The result is always -1. None of the outcommented variants would help.
By chance (honestly by searching :-) I found a snippet for replacing a backslash by a slash that worked. So I changed my code into:
string = "My STRING=15";
regx = new RegExp( "(\\d+)", "g" )
regx = /([A-Z]+)=(\d+)/;
regx = /(\d+)/g;
regx = /[\w]+/g
print( string.indexOf( regx ))
print( string.lastIndexOf( regx ))
print( string.replace( regx, "xXx" ))
Now the replacement always works, while the indices returned are always -1.
Does that mean that indexOf and lastIndexOf don't work with RegExpr ? Or did I miss something?