I have 2 regular expressions which work perfectly on regex101, but, on the sheet script, one (REGEX_RANGO) returns false when calling .test, and the other (REGEX_INVIDIDUAL) doesn't work at all.
(Note: I use a cell on the sheet to debug this kind of situation, I don't know if its a better one, if someone knows, please, post it!)
My current regular expressions are:
var REGEX_RANGO = /((?=(\d|\,))(\d{1,3}-\d{1,3})+(?=(\s|\,)))/gm;
var REGEX_INDIVIDUAL = /((?<=,)|(?:^(\d)))[^(,|\-)\n]+((?=,)|(?:\s))/gm;
Why i need both? Well, I have a form, which people can join values and the regular expressions can work on them.
Inputs are like:
*000-005,100,200,250-275,300*
:- REGEX_RANGO should get on the array the values [000,005,250,275]
- REGEX_INDIVIDUAL on another array should get [100,200,300]
*001,002,003,010-015*
:- REGEX_RANGO should get on the array the values [010,015]
- REGEX_INDIVIDUAL should get [001,002,003]
Hope someone knows how to handle this, thanks. You can find my current attemps here and here.
To be clear: this works ok on regex101, not on Google Sheet, maybe a scope or i need to scape the regular expression?
EDITED:
var REGEX_INDIVIDUAL = /((?<=,)|(?:^(\d)))[^(,|\-)]+(?=($|,))/gm;
var j = numeros_ingresados.match( REGEX_INDIVIDUAL )
SpreadsheetApp.getActiveSheet( ).getRange("F1").setValue( " >> j : " + j )
000-005,100,200,250-275,300
with theREGEX_RANGO
in regex101 I get the output you have with google app script