У меня есть этот текст:Условный Pattern
<pre id="lyricsText">
__Verse 1
At the starting of the week
At summit talks, you'll hear them speak
It's only Monday
Negotiations breaking down
See those leaders start to frown
It's sword and gun day
__Chorus 1
Tomorrow never comes until it's too late
__Verse 2
You could be sitting taking lunch
The news will hit you like a punch
It's only Tuesday
You never thought we'd go to war
After all the things we saw
It's April Fools' day
__Chorus 1 (R:2)
Tomorrow never comes until it's too late
__Verse 3
You hear a whistling overhead
Are you alive or are you dead?
It's only Thursday
You feel a shaking on the ground
A billion candles burn around
Is it your birthday?
__Chorus 1 (R:2)
Tomorrow never comes until it's too late
__Outro
Make tomorrow come, I think it's too late
</pre>
, и я стараюсь, чтобы захватить заголовки. Для этого я использую этот шаблон:
var headers = /__.*/g;
, который прекрасно работает, но я хочу, чтобы исключить (R:2)
или что-нибудь похожее на это. Я использую другой шаблон для захвата и редактирования (R:x)
частей:
/(\(R.{0,2}\))/g
Я не мог найти способ, чтобы заставить их работать вместе.
Как написать запись /__.*/
и если есть исключение /\(R.{0,2}\)/
?
Так '__Chorus 1 (R: 2)' вы хотите захватить '' __Chorus 1? – OGHaza
Да, это то, что я хочу делать. – akinuri