Article 53PVJ RegEx - Any better than this?

RegEx - Any better than this?

by
mddnix
from LinuxQuestions.org on (#53PVJ)
Hello All

I'm using RegEx to rename a lot of files. Following are some samples of the filename.
Code:$ ls -1N
01 Linux OS Introduction12m 58s.mp4
02 Subject Intro25s.mp4
03 Learning Objectives23s.mp4
04 Final Analysis3m 12s.mp4
I want to replace characters in bold to nothing. So, the regular expression I'm using is this. I'm also using Positive Lookahead Assertion for safety.
Code:([0-9]{1,2}[sm]{1}) ?([0-9]{1,2}[sm]{1})?(?=\.mp4$)Code:$ prename -nv 's/([0-9]{1,2}[sm]{1}) ?([0-9]{1,2}[sm]{1})?(?=\.mp4$)//' *.mp4
01 Linux OS Introduction12m 58s.mp4 -> 01 Linux OS Introduction.mp4
02 Subject Intro25s.mp4 -> 02 Subject Intro.mp4
03 Learning Objectives23s.mp4 -> 03 Learning Objectives.mp4
04 Final Analysis3m 12s.mp4 -> 04 Final Analysis.mp4Is this the correct way? Or can I optimize/shorten RegEx even better?

Thankslatest?d=yIl2AUoC8zA latest?i=G4eg0-gy99A:_yDPh6nq6uY:F7zBnMy latest?i=G4eg0-gy99A:_yDPh6nq6uY:V_sGLiP latest?d=qj6IDK7rITs latest?i=G4eg0-gy99A:_yDPh6nq6uY:gIN9vFwG4eg0-gy99A
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments