我有一个字符串值,它看起来像以下示例:
data:
130823 ~ Optics-Bottle Detect failure ~ L 0 ~ P 0 | 130824 ~ Optics-Bubble Detect failure ~ L 0 ~ P 0
Format:
ID: 130823
Description: Optics-Bottle Detect failure
Reps: L O
Pending: P 0
我的最终字符串基本上应该从连接字符串的每个部分中删除ID,因此通过查看上面的样本数据,期望输出应如下所示:
Optics-Bottle Detect failure ~ L 0 ~ P 0 | Optics-Bubble Detect failure ~ L 0 ~ P 0
一个字符串中可能包含N个部分。为了举例,我只列出了一个包含两个部分的示例字符串。
**我的正则表达式
我使用以下正则表达式,但它只能从字符串的第一个部分中删除ID。
var y = x.replace(/\d{6}\s~\s/g, "");