-1

我有这个:

#EXTM3U
#EXTINF:-1,ABC HD
http://AAAAAAAAAAAAAAA/BBBBBBBBBBBBBB/C.ts
#EXTINF:-1,DEF HD
http://FFFFFFFFFFFFFF/DDDDDDDDDDDDDDDDD/C.ts
#EXTINF:-1,GHI HD
http://SSSSSSSSSSSSSS/GGGGGGGGGGGGGG/C.ts

我需要一个带有两个捕获组的 javascript 正则表达式:

 (1) ABC HD
 (2) http://AAAAAAAAAAAAAAA/BBBBBBBBBBBBBB/C.ts

 (1) DEF HD
 (2) http://FFFFFFFFFFFFFF/DDDDDDDDDDDDDDDDD/C.ts

..... 等等。

4

1 回答 1

0

正则表达式

(http:\/\/(?:[a-zA-Z\/]+)\.ts)

描述

\# matches the character # literally
EXTINF: matches the characters EXTINF: literally (case sensitive)
[^,]+ match a single character not present in the list below
    Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
    , the literal character ,
, matches the character , literally
1st Capturing group ([^\n]+)
    [^\n]+ match a single character not present in the list below
        Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
        \n matches a line-feed (newline) character (ASCII 10)
\n matches a line-feed (newline) character (ASCII 10)
2nd Capturing group (http:\/\/(?:[a-zA-Z\/]+)\.ts)
    http: matches the characters http: literally (case sensitive)
    \/ matches the character / literally
    \/ matches the character / literally
    (?:[a-zA-Z\/]+) Non-capturing group
        [a-zA-Z\/]+ match a single character present in the list below
            Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
            a-z a single character in the range between a and z (case sensitive)
            A-Z a single character in the range between A and Z (case sensitive)
            \/ matches the character / literally
        \. matches the character . literally
        ts matches the characters ts literally (case sensitive)

输出

MATCH 1
    1.  [19-25] `ABC HD`
    2.  [26-68] `http://AAAAAAAAAAAAAAA/BBBBBBBBBBBBBB/C.ts`
MATCH 2
    1.  [80-86] `DEF HD`
    2.  [87-131]    `http://FFFFFFFFFFFFFF/DDDDDDDDDDDDDDDDD/C.ts`
MATCH 3
    1.  [143-149]   `GHI HD`
    2.  [150-191]   `http://SSSSSSSSSSSSSS/GGGGGGGGGGGGGG/C.ts`
于 2016-02-15T07:38:00.137 回答