Jump to content
Sign in to follow this  
wisem2540

Stringregexp trying to capture date

Recommended Posts

wisem2540

Here is a sample of what I want to evaluate

<td class="bottomTableDate" rowspan="2">2013-05-26</td>
        <td class="bottomTableName" rowspan="2"><span class="standardTrailerName" itemprop="name">Trailer 6 - 5.1 Audio</span></td>

        <td class="bottomTableResolution"><a href="http://videos.hd-trailers.net/LONE-RANGER_TLR-6-480p-HDTN.mp4" rel="lightbox[res480p 852 480]" title="The Lone Ranger - Trailer 6 - 5.1 Audio - 480p">480p</a></td>
        <td class="bottomTableResolution"><a href="http://videos.hd-trailers.net/LONE-RANGER_TLR-6-720p-HDTN.mp4" rel="lightbox[res720p 1280 720]" title="The Lone Ranger - Trailer 6 - 5.1 Audio - 720p">720p</a></td>
        <td class="bottomTableResolution"><a href="http://videos.hd-trailers.net/LONE-RANGER_TLR-6-1080p-HDTN.mp4

END SAMPLE

 

I would like my start point to be the beginning of the file, and my end point to be one of the filenames, like the 1080p file,  I have tried alot of things.  im trying to extract the date, like this

$string = StringRegExp($i, '(\d\d\d\d-\d\d-\d\d)http://videos.hd-trailers.net/LONE-RANGER_TLR-6-1080p-HDTN.mp4', 3)
_ArrayDisplay ($string)

Im not sure if my issue is with whitespace, or something else.  Can someone point me in the right direction please?

Share this post


Link to post
Share on other sites
PhoenixXL

#include <Array.au3>

$aArray = StringRegExp($sText, '(\d+-\d+-\d+)', 3)
_ArrayDisplay($aArray)

Small and limited approach.


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
wisem2540

Thank you, but I need the stopping point as well.  On a bigger scale, the source code will have many different movie trailers in it, each having a date before it.  So, I will need to basically start at the trailer the program has chosen, and work backwards, until it sees a date.

Thanks for the reply.

Share this post


Link to post
Share on other sites
Malkey

Maybe this.

#include <Array.au3>

ConsoleWrite(StringRegExpReplace(FileRead("FullPathFileName.txt"), '(?s).+?(\d{4}-\d{2}-\d{2}).+?(http://[^"]+1080p[^"]*).+?', @LF & '\1 "\2"') & @LF)
; Or
$string = StringRegExp(FileRead("temp-378.au3"), '(\d{4}-\d{2}-\d{2}|http://.+1080p[^"]*)', 3)
_ArrayDisplay($string)

Edit: Added this example which returns the last file after a date regardless of the file's resolution.

#include <Array.au3>

Local $aArr = StringRegExp(FileRead("FullPathFileName.txt"), '(?i)(\d{4}-\d{2}-\d{2}|http://[^"]*)', 3)
_ArrayDisplay($aArr, "Date plus all links")
Local $iFlag = 1
For $i = UBound($aArr) - 1 To 0 Step -1
    If StringLeft($aArr[$i], 4) = "http" And $iFlag Then ; First http element encountered from end of array - keep
        $iFlag = 0
    ElseIf StringLeft($aArr[$i], 4) = "http" And $iFlag = 0 Then ; Subsequent http element encountered before non-http element -erase.
        _ArrayDelete($aArr, $i)
    Else
        $iFlag = 1 ; A non-http element
    EndIf
Next
_ArrayDisplay($aArr, "Date with last link")
Edited by Malkey

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×