Hi, dear forum,
I need to check for a number in a string and then put that number into another variable.
I tried using this script:
It works, but it seems to check only for a 4 digit number (or \d{3} or \d{2}.........).
Now, basically, I need to upgrade this code so it can check for any kind of number (without considering its length) in the string.
Is that possible?
I need to check for a number in a string and then put that number into another variable.
I tried using this script:
Code:
var num = parseInt($gameVariables.value(27).match(/\d{4}/)[0]);
$gameVariables.setValue(184, (num>=1000 && num <= 9999) ? num : 0);
Variable 27 is where the string is stored, and variable 184 is the one where the number should be inserted.
It works, but it seems to check only for a 4 digit number (or \d{3} or \d{2}.........).
Now, basically, I need to upgrade this code so it can check for any kind of number (without considering its length) in the string.
Is that possible?