Regular expression to extract the year from a string

后端 未结 5 832
盖世英雄少女心
盖世英雄少女心 2020-12-19 22:54

This should be simple but i cant seem to get it going. The purpose of it is to extract v3 tags from mp3 file names in Mp3tag.

I have these strings I want to extract

5条回答
  •  星月不相逢
    2020-12-19 23:25

    You can use something like this \((\d{4})\)$. The first group will have your match.

    Explanation

    \(       # Match the character “(” literally
    (        # Match the regular expression below and capture its match into backreference number 1
       \d       # Match a single digit 0..9
          {4}      # Exactly 4 times
    )
    \)       # Match the character “)” literally
    $        # Assert position at the end of a line (at the end of the string or before a line break character)
    

提交回复
热议问题