• BiscuityCat@lemmy.world
    link
    fedilink
    arrow-up
    12
    ·
    6 days ago

    I never understood why are people scared of regular expressions. I love them and they can be quite usefull.

    Here is an example of one regex I wrote recently - it is used in replace:

    (?:^-\[[^[]+\]$| ?\[.+?\] ?)
    
      • BiscuityCat@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        4 days ago

        I have mentioned it in the comments below, but to explain it simply, I just wanted to remove all the bracketed text + a dash if there is no other text.

    • Funkt4st1c@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 days ago

      I started using regex because i need to rename a lot of my pirated media from “this_episode_uploaded_byXxXSuperEl33tSqwaaadXxX_MLP_s04_Episode7_bats.mkv”

      and linux deals with it very nicely. Much better than manual, anyways