这是本主题(Remove all character after matched character)
中我的问题的真实案例http://example.com/read.php/984.htm" target="_blank"> (đảo hải tặc) chap 499-3 [TV]
http://example.com/read.php/983.htm" target="_blank"> (đảo hải tặc) chap 499-2 [TV]
http://example.com/read.php/982.htm" target="_blank"> (đảo hải tặc) chap 499 [TV]
http://example.com/read.php/981.htm" target="_blank"> chapter 498 TV :11 siêu tân tinh
http://example.com/read.php/980.htm" target="_blank"> chapter 497 TV :cuộc phiêu lưu tại đảo bong bóng
http://example.com/read.php/979.htm" target="_blank"> (đảo hải tặc) chap 496 [TV]
http://example.com/read.php/978.htm" target="_blank"> chapter 495
http://example.com/read.php/977.htm" target="_blank"> (đảo hải tặc) 494
http://example.com/read.php/976.htm" target="_blank"> (đảo hải tặc) section 493 [TV]
http://example.com/read.php/975.htm" target="_blank">s chapter 492 TV " Duval mặt nạ sắt"
http://example.com/read.php/973.htm" target="_blank"> chap 490: Trở vỠnơi ấy.
http://example.com/read.php/972.htm" target="_blank"> (đảo hải tặc) chap 489
http://example.com/read.php/971.htm" target="_blank"> 488 :Bà i hát của cuộc sống
http://example.com/read.php/970.htm" target="_blank"> (đảo hải tặc) chap 487
http://example.com/read.php/969.htm" target="_blank"> chao 486 Cây Äà n DÆ°Æ¡ng Cầm
http://example.com/read.php/968.htm" target="_blank"> (đảo hải tặc) chap 485
http://example.com/read.php/967.htm" target="_blank"> Part 484
http://example.com/read.php/966.htm" target="_blank"> (đảo hải tặc) 483
http://example.com/read.php/965.htm" target="_blank"> chap 482
http://example.com/read.php/963.htm" target="_blank"> chapter 480
http://example.com/read.php/962.htm" target="_blank"> Chap 479
http://example.com/read.php/961.htm" target="_blank"> Chap 478
http://example.com/read.php/960.htm" target="_blank"> (đảo hải tặc) chap 477
http://example.com/read.php/959.htm" target="_blank"> (đảo hải tặc) chap 476
http://example.com/read.php/958.htm" target="_blank"> (đảo hải tặc) chap 475
http://example.com/read.php/957.htm" target="_blank"> (đảo hải tặc) chap 474
http://example.com/read.php/956.htm" target="_blank"> (đảo hải tặc) chap 473
http://example.com/read.php/955.htm" target="_blank"> (đảo hải tặc) chap 472
http://example.com/read.php/954.htm" target="_blank"> chap 471
http://example.com/read.php/953.htm" target="_blank"> chap 470
http://example.com/read.php/952.htm" target="_blank"> chap 469 (tiếp theo NXB)
http://example.com/post/6050/" target="_blank"> chap-0 (Strong World)
如何删除第一个columd和“number x”之间“number x”+之后的所有字符...我想要这样的输出
http://example.com/read.php/982.htm 499-3
http://example.com/read.php/982.htm 499-2
http://example.com/read.php/982.htm 499
http://example.com/read.php/981.htm 498
http://example.com/read.php/980.htm 497
http://example.com/read.php/979.htm 496
http://example.com/read.php/978.htm 495
http://example.com/read.php/977.htm 494
注意:“数字x”有时是499-1 499-2 499-3
答案 0 :(得分:1)
by sed
sed -n 's/\(.*htm\)"[^0-9]*\( [-0-9]*\).*/\1 \2/p' infile
答案 1 :(得分:0)
在perl:
perl -ne '$_ =~ s/(.*htm)"[^0-9]*( [-0-9]*).*/$1 $2/; print $_' < mydata
答案 2 :(得分:0)
使用perl:
perl -pe 's/(?<=htm)\D*(\d+).*/ $1/' file