Hi there,
I am trying to get my head around for filtering cue numbers (as 1m01, 1M5, 1m10B or 1m7: so basically 1 digit, letter "m or M", another number -with 1 or 2 digits) and an optional ending letter, which can be lowercase or uppercase. I think I got the regex correct but I am not getting the matching option right, and it ouputs "null" always:
var text = "I am working today on 1m10, 2m5 and 3m10B";
var regex = /\d [mM] \d{1,2}[\w\W]?/g;
var matches = text.match(regex);
// var matches = text.filter(n => n.match(regex));
log(matches);
// var text = "OEV_1m10_v1a_05060809";
// let cue = text.match(/\d [mM] \d{1,2}[\w\W]?/);
// var regex = /\d [mM] \d{1,2}[\w\W]?/g;
// var text = "OEV_1m10_v1a_05060809";
// let cue = text.match(regex);
// log(text);
// log(cue);
Could you provide any help on how to get the right string for the "cue" variable? I am trying different things, but no success... I am sure it's a little thing, but I am getting crazy about not getting it right! ;-) Thank you!
- Raphael Sepulveda @raphaelsepulveda2023-10-14 15:35:29.620Z
@Vanessa_Garde! You just have to remove the spaces in your regex. Remember that those count towards the search. The way you have it now, it's looking for a string that looks like this: "1 m 10".
Here's the corrected regex:
var regex = /\d[mM]\d{1,2}[\w\W]?/g;
- VVanessa Garde @Vanessa_Garde
Great!!! Many thanks @raphaelsepulveda !!! I was getting craaazy!! ;-)
Always great to get your feedback! Many thanks!!!