Autohotkey在正则表达式之前获取所有内容

时间:2016-12-26 05:22:00

标签: autohotkey

我试图在字符串中获取电影名称(不带点)。

例如:

“Matrix.1999.LIMITED.720p.BluRay” 将会 “黑客帝国”

另外, “Max.Steel.2016.1080p.BluRay” 将会 “Max Steel”

我已经做了以下但是没有用

Haystack =Max.Steel.2016.1080p.BluRay
TheYear := RegExMatch(Haystack, "\d{4}\b")
StringGetPos, YearPostion,Haystack,%TheYear%
StringLeft, MovieName,Haystack,%YearPostion%
MsgBox, %MovieName%

1 个答案:

答案 0 :(得分:1)

用空格替换所有点,搜索年份,并修剪不必要的空格:

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%|
}