我有这个:
#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中使用两个捕获组的regual表达式:
(1) ABC HD
(2) http://AAAAAAAAAAAAAAA/BBBBBBBBBBBBBB/C.ts
(1) DEF HD
(2) http://FFFFFFFFFFFFFF/DDDDDDDDDDDDDDDDD/C.ts
.....等等。
答案 0 :(得分: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`