Kidney Posted September 18, 2013 Posted September 18, 2013 So im making a script that organizes TV shows. i have figured most of it out but im trying to find the portion of the title that contains the Season number and Episode number. (ie S01E13) is there and easy way to search for the "S" and "E" in a string with any 2 random numbers in between them and after the "E"? here is what i tried just as a very wild guess: Func FindSeasonEpisode($FileName) $result = StringInStr($FileName, "S**E**") ConsoleWrite($result & @CRLF) EndFunc
water Posted September 18, 2013 Posted September 18, 2013 Please have a look at StringRegExp. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
tester123 Posted September 18, 2013 Posted September 18, 2013 (edited) Func FindSeasonEpisode($FileName) $result = StringRegExp ($FileName, "S\d\dE\d\d",0); ConsoleWrite($result & @CRLF) EndFunc Try this for For S01E13 d accepts any digit. The helpfile has a detailed list of options you could use Edited September 18, 2013 by tester123
Kidney Posted September 18, 2013 Author Posted September 18, 2013 (edited) to be completely honest water, i would like to use stringregexp but i cant figure it out for the life of me. if i had an example of how i would use it in this situation then i could probably mess with it enough to do more elaborate things but for now, tester123's solution works for me. if you dont mind water, i would really like to see how i would use that function in my situation. if its not too much of a hassle. @tester123 ty ty. this is what i was looking for EDIT: tried the d but im getting a 0 for my results with StringInStr. when i do StringRegExp with the d's i get a 1 which is a match but how do i get the position like i do with StringInStr?? Edited September 18, 2013 by Kidney
Kidney Posted September 18, 2013 Author Posted September 18, 2013 AH HA! i got it! lol Func FindSeasonEpisode($FileName) $result = StringRegExp($FileName, "S\d\dE\d\d", 1) ConsoleWrite("StringRegExp " & $result[0] & @CRLF) Return $result[0] EndFunc changed the mode to 1. but im not sure why it writes it to an array with only one entry..... explain anyone??
MHz Posted September 18, 2013 Posted September 18, 2013 Perhaps it is easier to use StringRegExpReplace to do, depending on your task. $string = 'S01E13 Some episode' $var = FindSeasonEpisode($string) MsgBox(0, '$var', $var) Func FindSeasonEpisode($FileName) Return StringRegExpReplace($FileName, "\A\w(\d+)\w(\d+) (.*)", '\1-\2 \3') EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now