Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

请问用 Regex 如何删除行数是偶数的?

抱歉,我是Regex超级菜鸟
请问我想将行数是偶数的整行删除。

举例
输入。

Line11010
Life2202
Lixf23232
Lixcv003954
Lixvxc4504350
Lixe30472304723

期望结果。

Line11010
Lixf23232
Lixvxc4504350

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
`Line11010
Life2202
Lixf23232
Lixcv003954
Lixvxc4504350
Lixe30472304723
`.replace(/(
|
|
).*?(1|$)/g,'$2')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...