I want to use this as part of a script where the input is something like
Some.Text.S01E05.More.Text.Here or
Different.Text.Now.S11E02.Even.More.Text.Here
and the output I want is
Some.Text
Different.Text.Now
It's probably really easy with RegEx, but how?
how to grab part of the string before 'S??E??' ? Topic is solved
Re: how to grab part of the string before 'S??E??' ? Topic is solved
Code: Select all
Text =
(
Some.Text.S01E05.More.Text.Here or
Different.Text.Now.S11E02.Even.More.Text.Here
)
; store matches in array:
Matches := []
loop, Parse, Text, `n, `r
{
RegExMatch(A_LoopField, ".*(?=\.S\d\dE\d\d)", M)
Matches.Push(M)
}
; display contents of array:
for Each, Match in Matches
Out .= Match "`n"
MsgBox, % Out
Re: how to grab part of the string before 'S??E??' ?
Sorry, I can't get it to work properly, and it might be my fault. What I meant in my post above is that the input is something like
Some.Text.S01E05.More.Text.Here
or
Different.Text.Now.S11E02.Even.More.Text.Here
and the output I want is
Some.Text
or
Different.Text.Now
So there's only ever one line of input.
Some.Text.S01E05.More.Text.Here
or
Different.Text.Now.S11E02.Even.More.Text.Here
and the output I want is
Some.Text
or
Different.Text.Now
So there's only ever one line of input.
Re: how to grab part of the string before 'S??E??' ?
Code: Select all
Text := "Some.Text.S01E05.More.Text.Here"
RegExMatch(Text, ".*(?=\.S\d\dE\d\d)", Match)
MsgBox, % Match
Re: how to grab part of the string before 'S??E??' ?
Re: how to grab part of the string before 'S??E??' ?
FYI - My code uses the right RegEx pattern.
Re: how to grab part of the string before 'S??E??' ?
Thanks, boiler, you're the best! Works perfectly now.
Thanks Chunjee, I'll have a look.
Thanks Chunjee, I'll have a look.
Re: how to grab part of the string before 'S??E??' ?
I want to expand the script where I'm using this, how would I still have
Some.Text.S01E05.More.Text.Here
as input and
Some.Text.S01E05
as a secondary output (as another string)?
Some.Text.S01E05.More.Text.Here
as input and
Some.Text.S01E05
as a secondary output (as another string)?
Re: how to grab part of the string before 'S??E??' ?
Code: Select all
Text := "Some.Text.S01E05.More.Text.Here"
RegExMatch(Text, "(.*)\.S\d\dE\d\d", Match)
MsgBox, % Match1 "`n" Match
Re: how to grab part of the string before 'S??E??' ?
Perfect, thanks again!
Who is online
Users browsing this forum: roysubs and 291 guests