简体   繁体   中英

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. 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). The problem is I often have 5-100+ reference numbers that need <sup>'ing.

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.

I could either do 'all numbers' get that treatment [0-9], or for bonus points only numbers that come after a full stop. 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 .

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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