Modified the regex little bit to match the numbers and text. You can play around here
Explanation
to capture a group you need to wrap the regex into ()
this will capture as a group.
to do the named capturing you can (?<name_of_group>)
and then you can access by name.
Here goes the matching process.
[a-z]{2}
match 2 char from a-z
[a-zA-Z0-9]
match any char of a-z or A-Z or 0-9
g
means global flag i.e. match all.
i
means ignore case.
var r = /FDIP_([a-z]{2}-[A-Z]{2})-[a-z]{2}_Text_v1_[0-9A-Z]{8}_[A-Z0-9]{14}.txt/gi;
let t = 'FDIP_en-gb-nn_Text_v1_YYYYMMDD_SequenceNumber.txt';
let dd = r.exec(t);
console.log(dd[1]);
This is example of group capturing
See the name in the regex
and the object destructing name is matching.
const { groups: { language } } = /FDIP_(?<language>[a-z]{2}-[A-Z]{2})-[a-z]{2}_Text_v1_[0-9A-Z]{8}_[A-Z0-9]{14}.txt/gi.exec('FDIP_en-gb-nn_Text_v1_YYYYMMDD_SequenceNumber.txt');
console.log(language);