toxicdav3 Posted March 7, 2009 Posted March 7, 2009 (edited) I tired to use the stringregexp from the help file to split the items in a rss feed but it didn't return anything. Didn't work: $array = StringRegExp($rss, '<(?i)item>(.*?)</(?i)item>', 1, 1) Did work: $array = _StringBetween($rss, '<item>', '</item>') Also looking to split up a file name into 3 parts and extract the season and episode numbers if anyone can help me. Show Name *split* s01e01 *split* WS PDTV XviD RLSGROUP Show Name to $show s01e01 can be any of the following... s01e01 1x01 2009 03 01 odd: Season 1 Season 1 Ep 1 Season 1 Episode 1 01x01 101 2008to different strings if the info is available $season $episode $year $day $month WS PDTV XviD RLSGROUP to $tags Please help stringregexp confuses me completely and cant even get the simple item thing working! cheers Edited March 7, 2009 by toxicdav3 Layered Networks - Hosting Solutions
Paulie Posted March 7, 2009 Posted March 7, 2009 Meep... HTML Code to-be-parsed would make it much easier to help.
toxicdav3 Posted March 7, 2009 Author Posted March 7, 2009 What do you mean? Layered Networks - Hosting Solutions
Ascend4nt Posted March 7, 2009 Posted March 7, 2009 (edited) toxicdav3, you are looking for text between <item> and </item>, correct? Your examples do not have either of those strings in them, that's the problem - we need to see what it is you are pulling from.Also, using option 1 in StringRegExp will return only one result per pair of parentheses, so in your example it will only return a 1 element array (if something matches). Option 3 will do a repeated search for those items until it reaches the end of the string.*edit: oops, just realized you are talking about two different things. The 2nd item we'd also need to know what specifically separates the season/episode from the rest of the text.For example, is it 'ATVShow.s1e01.dvd.info.txt' or 'A TV Show 1x01.info.txt' or 'A-TV-Show on NBC Season 1 Ep 1 info.txt'If it can be any of the above, you're not going to wind up with a Regular Expression that can do all the work for you. There has to be some type of logical consistent order. And what if the TV Show itself has any of those characters? Like, if they had a TV series based on the movie: 'Open Season Season 1 Ep 2'. How are you going to distinguish without a given order, or special separators.. it's one thing to find consistent formatted things like s1e12 or 3x04, but the other random possibilities requires a lot of string interpreting. Edited March 7, 2009 by ascendant My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
toxicdav3 Posted March 7, 2009 Author Posted March 7, 2009 (edited) I'll just leave it to stringbetween for now. How would i go about splitting this and using StringRegExp to get the season and episode? All dots, dashes, etc are replaced by spaces so there is no need to worry about that.Show Name ~ s01e01 ~ WS PDTV XviD RLSGROUP Edited March 7, 2009 by toxicdav3 Layered Networks - Hosting Solutions
weaponx Posted March 7, 2009 Posted March 7, 2009 RSS is xml, which there is an XML UDF for. I have also demonstrated retrieving values from RSS with it.http://www.autoitscript.com/forum/index.ph...hl=xml++wrapper
Ascend4nt Posted March 7, 2009 Posted March 7, 2009 I'll just leave it to stringbetween for now. How would i go about splitting this and using StringRegExp to get the season and episode? All dots, dashes, etc are replaced by spaces so there is no need to worry about that. Show Name ~ s01e01 ~ WS PDTV XviD RLSGROUP Okay, the simplest way - if you are *always* getting s##e##, and there aren't other matches in the string: StringRegExp($Str,"(?i)s(\d{1,2})e(\d{1,2})",1) (Note I let it take 1 or 2 digits. If its *always* 2, just change it to {2}) Now if it's something *between* ~'s and a space, then you can just change the above to add the tildes and space: "(?i)~ s(\d{1,2})e(\d{1,2}) ~" Does that help? Results: [0] = 01 [1] = 01 My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Malkey Posted March 7, 2009 Posted March 7, 2009 These regular expressions are not fully tested on all input string variations. Hope they help you along.expandcollapse popup$sStr = "Show Name ~ s01e01 ~ WS PDTV XviD RLSGROUP" ; Separating on space~space $Show = StringRegExpReplace($sStr, " ~ .*$", "") MsgBox(0, "$Show", $Show) ; Separating on space~Space $s01e01 = StringRegExpReplace($sStr, $Show & " ~ | ~ .*$", "\1") MsgBox(0, "Season Episode", $s01e01) $tags = StringRegExpReplace($sStr, "^.*" & $s01e01 & " ~ ", "") MsgBox(0, "$tags", $tags) #cs s01e01 1x01 2009 03 01 odd: Season 1 Season 1 Ep 1 Season 1 Episode 1 01x01 101 2008 #ce $season = StringRegExpReplace($s01e01, "(?i)(s\d{1,2}|\d{1,2}|200\d|Season \d{1,2})(?:.*)", "\1") MsgBox(0, "$season", $season) $episode = StringRegExpReplace($s01e01, "(?i)(?:" & $season & ")(e\d{1,2}|x\d{1,2}|Ep \d{1,2}|Episode \d{1,2}|\d{1,2})", "\1") MsgBox(0, "$episode", $episode) If StringRegExp($sStr, "(20\d{2}|19\d{2})", 0) = 1 Then $year = StringRegExpReplace($sStr, "(?:.*)(20\d{2}|19\d{2})(?:.*)", "\1") Else $year = "Not Found" EndIf MsgBox(0, "$year", $year)
Ascend4nt Posted March 7, 2009 Posted March 7, 2009 Malkey, you're one serious PCRE freak! hahaha.. how many PCRE's is that for one function?! yikes.. talk about excessive My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
toxicdav3 Posted March 8, 2009 Author Posted March 8, 2009 (edited) Thanks for your help but the "~" aren't included in the name. That's why I had it as *split* in the original post. Edited March 8, 2009 by toxicdav3 Layered Networks - Hosting Solutions
Authenticity Posted March 8, 2009 Posted March 8, 2009 As Paulie said, HTML code to be parsed can help in recognizing the pattern to match and to not match and if it's necessary at all.
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