Jump to content
Sign in to follow this  
d0n

problem with StringRegExp

Recommended Posts

d0n

I am trying to get some data from a string

$Info = StringRegExp($Source, 'target="_blank">?\s?(?:<strong>|title="">)?(.*?)\s(?i:Ch?H?\s*?(\d+)|(\d+)).torrent', 1)

There are 2 different types of names

target="_blank" title="">TVSHOWNAME 2010-01-16.torrent

target="_blank" title="">TVSHOWNAME CH01.torrent

I want to get

1. TVSHOWNAME (this part is working)

2. either 20100116 or 01 (01 works but not sure how to get the 20100116 to work)

Share this post


Link to post
Share on other sites
Malkey

This might help.

#include <Array.au3>

Local $Source = 'target="_blank" title="">TVSHOWNAME 2010-01-16.torrent' & @CRLF & _
        'target="_blank" title="">TVSHOWNAME CH01.torrent'

Local $Info = StringTrimRight(StringRegExpReplace($Source, _
        'target=.*?="">(.*?)\s(?:[^\d]*)([\d]+)(?:[^\d]?)([\d]{0,2})(?:[^\d]?)([\d]{0,2})\.torrent', _
        "\1 \2\3\4 "), 2) ; 2 spaces after \1 and 2 spaces after \4
ConsoleWrite($Info & @CRLF)

Local $aInfo = StringSplit($Info, " ", 3) ; 2 spaces within " "

_ArrayDisplay($aInfo)

Edit: It appears the 2 spaces auto-change into 1 space.

So please check that the 3 places that require 2 spaces do have 2 spaces and not 1 space.

Edited by Malkey

Share this post


Link to post
Share on other sites
d0n

thanks for the help, never thought of using stringregexpreplace :D

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.