Jump to content
Sign in to follow this  
jjj

stringregexp help

Recommended Posts

jjj

i am trying to return the line shown below, which is in a text file along with hundreds of other lines of data:

The Sopranos @ s06e12 @ Kaisha @[ 04-Jun-2006 ]

using this search string:

The Sopranos - Kaisha .mpg

I know I can do this with string in string, but I want to use reg. expressions so i can add some fuzzy logic into it eventually. Note that there is a space bofre the line of text in the first line shown, but not in the second line, but there is a space after the episode name and before the ".mpg".

Can anyone help me?

EDIT: I figured out the regexp for this(i attached the code below), but it there a way to match case insensitive?, and how would i do it letter by letter or word by word? (so i can have it return a match if for example the search string was "the sopranos - the kaisha .mpg" (notice the "the" in the episode name, and the case of the whole string)

here is my initial code:

$filename = StringSplit("The Sopranos - Kaisha .mpg", " - ", 1) 


$showname = $filename[1]
$episodename = $filename[2]
$episodename = stringsplit($episodename, " .", 1)
$episodename = $episodename[1]
$listfile = fileopen("c:\program files\wget\test.txt", 0)

While 1
    $line = FileReadLine($listfile)

    If @error = -1 Then ExitLoop
;MsgBox(0,"",":"&$showname&":")
;MsgBox(0,"",":"&$episodename&":")
;MsgBox(0,"",$line)
    if StringRegExp($line, $showname) = 1 Then
        if StringRegExp($line, $episodename) = 1 Then
            ExitLoop
        EndIf
    EndIf
Wend

MsgBox(0,"",$line)
Edited by jjj

Share this post


Link to post
Share on other sites
Uten

Somthing like this?

Msgbox(0,"",StringRegExp("The Sopranos @ -- Found KasAThoy", "(.*(?i)sopranos.*kasa(?i).*)"))

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.