我是正则表达式的新手,而且我还没有找到如何在'之前获取文字:'但不包括它。
我在代码中进行了替换,因此我需要在'之后选择所有文字:'
这是demo:
/(?!.*:)./
感谢您的帮助。
答案 0 :(得分:1)
似乎你需要
models.ForeignKey
<强>详情
const rx = /^[^:\r\n]+(?=:)/gm;
const str = `Hilary: YOU KNOW, THIS IS NOT WHY I CAME HERE.
Devon: DOESN'T MATTER.
Hilary: IT DOES. DEVON, WHEN I SAY THAT I'M TIRED OF SNEAKING AROUND, I MEANT IT.
Devon: DON'T GET UPSET, THOUGH.
Hilary: HOW CAN I NOT? I MEAN, LOOK AT WHAT I DID.
Devon: HONEY, HONEY, WE'RE IN LOVE WITH EACH OTHER. OKAY? AND WE KNOW EXACTLY WHAT WE HAVE TO DO. WE'RE GONNA TELL NEIL THE TRUTH.
Hilary: NOW?
Dr. Barrett: I THINK YOU CAN PROVIDE SOME VALUABLE INSIGHT INTO PHYLLIS NEWMAN'S RECENT STATE OF MIND.`;
document.body.innerHTML = "<pre>" + JSON.stringify(str.match(rx), 0, 4) + "</pre>";
- 字符串开头^
- [^:\r\n]+
,CR和LF :
- 当前位置右侧必须有(?=:)