I am having trouble to create a regular expression that returns only a part of a string.
Passing the following strings:
/path/of/the/file/1 - 2 - Lecture 1.2_ Max Bense (13_49).mp4
/path/of/the/file/1 - 3 - Lecture 1.3_ Michael Friedman (12_15).mp4
/path/of/the/file/2 - 1 - Lecture 2.1_ Paul Feyerabend (12_55).mp4
/path/of/the/file/2 - 2 - Lecture 2.2_ Alhazen (11_37).mp4
/path/of/the/file/3 - 2 - Lecture 3.2_ Study Case - Dominicus Gundissalinus (14_30).mp4
/path/of/the/file/3 - 3 - Lecture 3.3_ Study Case - Carl Friedrich von Weizsacker (11_48).mp4
It should return only the following parts respectively:
Max Bense
Michael Friedman
Paul Feyerabend
Alhazen
Study Case - Dominicus Gundissalinus
Study Case - Carl Friedrich von Weizsacker
Use PCRE and Positive Lookbehind
If you have access to a regular expression engine that supports PCRE expressions, you can use positive lookbehind to get just the text you want from your MP3 listings. For example:
Use Sed
If you don’t have a Perl-compatible grep, then you can use sed instead. It’s a lot less readable, but a lot more portable. For example: