fork download
  1. str = "ABC-EDFGH-JLG-Sample-3Q17-fIS.pdf
  2. 2Q13 ABC MF PM Example_fIS.pdf
  3. 03Q1_FIS.pdf
  4. 05Q1 ABC_IS.pdf"
  5.  
  6. puts str.gsub(/^.*?(?:(\d\d)Q(\d)|(\d)Q(\d\d))(?!\d)/, '20\1\4Q\2\3_\0')
Success #stdin #stdout 0.01s 5872KB
stdin
Standard input is empty
stdout
2017Q3_ABC-EDFGH-JLG-Sample-3Q17-fIS.pdf 
2013Q2_2Q13 ABC MF PM Example_fIS.pdf
2003Q1_03Q1_FIS.pdf 
2005Q1_05Q1 ABC_IS.pdf