需要更多正则表达式调整建议
感谢 SO 的帮助,我正在向大型参考文件添加分隔符。现在就快到了。我有一个从 SO 成员那里收到的正则表达式,它允许我添加“|”作者和年份之间。我知道需要添加“|”文章和出版物之间。我想出的规则是我想添加“|”在出版物名称中“:”之前的最后一个句点(点)之后。我尝试编辑我对此的积极展望,但似乎不起作用。我一如既往地感谢您对此的意见。提前致谢。
实际上我可能甚至不需要指定后面的 3 个“|”规则。主要的事情是匹配“:”之前的最后一个句点。那是正确的吗?即便如此,我的正则表达式似乎不起作用。
^((?:[^|]+\|){3}.*?\.)(?=\:)
122| Ryan, T.N. |2002. |Some article name here. Publication name 2: 101-105.
I'm getting through adding delimiters to a large references file thanks to help from SO. Almost there now. I have a regex which I received from an SO member which allowed me to add the "|" between the author and year. I know need to add "|" between the article and publication. The rule I cam up with is that I want to add the "|" after the last period(dot) that precedes the ":" in the publication name. I tried editing my positive look ahead for this but it does not seem to work. I would appreciate your input on this as always. Thanks in advance.
Actually I probably don't need even to specify the after 3 "|" rule. The main thing would be to match to the last period that precedes the ":". Would that be correct. Even so my regex does not seem to be working.
^((?:[^|]+\|){3}.*?\.)(?=\:)
122| Ryan, T.N. |2002. |Some article name here. Publication name 2: 101-105.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,有两个问题:
尝试:
看到区别了吗? (删除了
?
,添加了[^:]*
)Okay 2 problems:
Try:
See the difference? (Removed a
?
, added a[^:]*
)