Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

Problem with RegExpr

$
0
0

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?


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>