简体   繁体   English

VSCode(或其他工具)自动将<sup>标签</sup>添加<sup>到参考编号</sup>

[英]VSCode (or other tool) auto add <sup> tags to reference numbers

I often have to copy large pharma or legal text and translate them for use on the web - either through a CMS or through direct code. 我经常必须复制大型药品或法律文字,然后将其翻译为可通过CMS或直接代码在网络上使用。 Sometimes these documents are really large. 有时这些文件确实很大。 Now when I copy the text and paste into VSCode (or sublime, or the CMS etc) it generally pastes everything as striaght text without the formatting (which is great). 现在,当我复制文本并将其粘贴到VSCode(或sublime或CMS等)中时,通常会将所有内容粘贴为条带文本,而无需设置格式(很棒)。 The problem is I often have 5-100+ reference numbers that need <sup>'ing. 问题是我经常有5-100多个需要<sup>的参考号。

I could write a small php / js script to do this, but unsure of the exact regex and not knowing how to write VSCode extensions, is there something out there that might do this. 我可以编写一个小的php / js脚本来执行此操作,但是不确定确切的正则表达式并且不知道如何编写VSCode扩展,那里是否有可能执行此操作。

I could either do 'all numbers' get that treatment [0-9], or for bonus points only numbers that come after a full stop. 我可以用“所有数字”进行处理[0-9],也可以仅用句号之后的数字作为奖励积分。 Or for a full on bonus new car, the complete regex would be numbers that appear after a full stop OR are at the end of the line. 或者对于满额奖金的新车,完整的正则表达式将是在句号之后出现的数字,或者是在行尾。 Ie

Some text1,2
Some text.1,2,3
Some other text.1,2,24 Lets carry on writing

Would all get caught. 都会被抓住的。 But I'd be happy at just capturing all the numbers if thats easier. 但是,我很乐意仅捕获所有数字,如果那样的话。

Thanks a ton in advance 提前感谢一吨

Take a look at regex101 demo . 看看regex101演示

I added a few other cases, you can see what matched and what didn't. 我添加了其他一些案例,您可以看到匹配的内容和不匹配的内容。 Let me know if I guessed wrong on what should be a match or not. 让我知道我是否猜错了什么该匹配。

(\.(\d,?)+)|((\d,?)+)$

Digits with/without commas after a period 句点后带/不带逗号的数字

OR 要么

digits with/without comma at end of line 行尾带/不带逗号的数字

Replace with $1$3<sup> 替换为$1$3<sup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM