search

Home  >  Q&A  >  body text

javascript - Convert some fixed format documents into format documents with a tag

Those who report problems, please simply take a look at the problem carefully and see if you can solve it before reporting it. This is not about converting txt to html. Reporting the problem without reading it is really high quality!

The document format is as follows:
https://www.baidu.com
You will know it by Baidu

https://www.zhihu.com
Zhihu

https://www.github.com
Github

http://m.sina.com/beta
Sina Weibo

…………

I want to convert this format into link text wrapped in html a tags, for example:
You will know it in Baidu
Zhihu
Gihub
Sina Weibo
How to achieve it ?

怪我咯怪我咯2804 days ago601

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-18 10:48:16

    An idea, not verified yet

    Regular matching newline, $1 is the link, $2 is the text. Then replace it with regular expression to generate the link text you want

    reply
    0
  • Cancelreply