typescript 从字符串中删除第一行
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript 从字符串中删除第一行相关的知识,希望对你有一定的参考价值。
const content = `5338472179@chatroom:\n<sysmsg type=\"sysmsgtemplate\">\n\t<sysmsgtemplate>\n\t\t<content_template type=\"tmpl_type_profile\">\n\t\t\t<plain><![CDATA[]]></plain>\n\t\t\t<template><![CDATA[\"$username$\"邀请你加入了群聊,群聊参与人还有:$others$]]></template>\n\t\t\t<link_list>\n\t\t\t\t<link name=\"username\" type=\"link_profile\">\n\t\t\t\t\t<memberlist>\n\t\t\t\t\t\t<member>\n\t\t\t\t\t\t\t<username><![CDATA[wxid_j76jk7muhgqz22]]></username>\n\t\t\t\t\t\t\t<nickname><![CDATA[林贻民]]></nickname>\n\t\t\t\t\t\t</member>\n\t\t\t\t\t</memberlist>\n\t\t\t\t</link>\n\t\t\t\t<link name=\"others\" type=\"link_plain\">\n\t\t\t\t\t<plain><![CDATA[诺、linyimin说]]></plain>\n\t\t\t\t</link>\n\t\t\t</link_list>\n\t\t</content_template>\n\t</sysmsgtemplate>\n</sysmsg>\n"`
function removeFirstLine(content: string): string {
const lines = content.split('\n')
lines.splice(0, 1)
return lines.join('\n')
}
function removeFirstLine(content: string): string {
return content.replace(/^[^\n]+\n/, '')
}
以上是关于typescript 从字符串中删除第一行的主要内容,如果未能解决你的问题,请参考以下文章