Reputation: 65
I am trying to get the movie name (without the dots) in a string.
For example:
"Matrix.1999.LIMITED.720p.BluRay" would be "Matrix"
Also, "Max.Steel.2016.1080p.BluRay" would be "Max Steel"
I have made the below but its not working
Haystack =Max.Steel.2016.1080p.BluRay
TheYear := RegExMatch(Haystack, "\d{4}\b")
StringGetPos, YearPostion,Haystack,%TheYear%
StringLeft, MovieName,Haystack,%YearPostion%
MsgBox, %MovieName%
Upvotes: 0
Views: 64
Reputation: 25752
Replace all of the dots with whitespace, search for the year, and trim the unnecessary whitespace:
Haystack = Max.Steel.2016.1080p.BluRay
StringReplace, Haystack, Haystack , . , %A_Space% , All
TheYear := RegExMatch(Haystack, "(1|2)\d\d\d")
if( TheYear > 0 )
{
TheYear--
StringLeft, MovieName,Haystack,%TheYear%
MovieName := Trim( MovieName ) ;
MsgBox, |%MovieName%|
}
Upvotes: 1