string.gsub problem

Discuss your Lua playlist, album art and interface scripts.
Tiwas
Blank Cone
Blank Cone
Posts: 17
Joined: 21 Jul 2012 14:28

string.gsub problem

Postby Tiwas » 25 Jul 2012 23:04

Hi,
I'm hoping someone could share some light on this for me. I'm trying to get the show name, season, episode and episode name out of a file's name. However, even though I'm pretty sure my regex has been lua-fied correctly it just returns the whole string to me.

This is what I have (title = "Continuum S01E06 Time's Up")

Code: Select all

local show_name = string.gsub(title, "(.+)%s[sS](%d{1,2})[eE](%d{1,2})%s(.*)", "%1") local show_season = string.gsub(title, "(.+)%s[sS](%d{1,2})[eE](%d{1,2})%s(.*)", "%2") local show_season_episode = string.gsub(title, "(.+)%s[sS](%d{1,2})[eE](%d{1,2})%s(.*)", "%3") local show_episode_name = string.gsub(title, "(.+)%s[sS](%d{1,2})[eE](%d{1,2})%s(.*)", "%4") vlc.msg.info("Show name: " .. show_name) vlc.msg.info("Season: " .. string.gsub(title, "(.+)%s[sS](%d{1,2})[eE](%d{1,2})%s(.*)", "%2"))--show_season) vlc.msg.info("Episode: " .. show_season_episode) vlc.msg.info("Episode name: " .. show_episode_name)
To which I'm getting the following:

Code: Select all

[0246bf10] lua generic: Show name: Continuum S01E06 Time's [0246bf10] lua generic: Season: Continuum S01E06 Time's Up [0246bf10] lua generic: Episode: Continuum S01E06 Time's Up [0246bf10] lua generic: Episode name: Continuum S01E06 Time's Up
Anyone able to help me out here?

Tiwas
Blank Cone
Blank Cone
Posts: 17
Joined: 21 Jul 2012 14:28

Re: string.gsub problem

Postby Tiwas » 25 Jul 2012 23:40

I managed to simplify it into "(.-)[%s ][sS](%d*)[eE](%d*)[%s ](.*)", which works. I don't like losing accuracy, but...;)


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 2 guests