First, I donβt know if this is really possible, but I want to repeat the regex pattern. I am using a template:
sed 's/[^-\t]*\t[^-\t]*\t\([^-\t]*\).*/\1/' films.txt
entrance
250. 7.9 Shutter Island (2010) 110,675
Will return:
Shutter Island (2010)
I map all the tabs (250.), then the tab, and then all the tabs (7.9), and then the tab. Then I love the name of the movie, and then match all the other characters (110 675).
This works well, but I study the regex and it looks ugly, the regex [^ - \ t] * \ t is repeated right after it, is there a way to repeat this as if you can use a character like {2,2}?
I tried ([^-\t]*\t){2,2} (and options), but I assume I'm trying to match [^-\t]*\t\t?
Also, if there is any way to make my above code shorter and cleaner, any help would be greatly appreciated.
source share