0

I've got the following symbols in my text:

V is 100 m³, and square is 12 m²

I need to replace these symbols with normal once:

V is 100 m3, and square is 12 m2

I'm stuck with the following RegExp:

var result = text.repalce(/³/, '3').replace(/²/, '2');

It works fine but I'd like to have universal regexp that will cover all such digits in uppercase (1,2,3,4....).

Please help me with that.

Erik
  • 14,060
  • 49
  • 132
  • 218
  • This may be helpful: https://stackoverflow.com/questions/17908593/how-to-find-the-unicode-of-the-subscript-alphabet – turtlemonvh Nov 28 '20 at 19:54
  • The digits are not in "uppercase". We are talking about special characters. Your regex solution seems to be pretty reasonnable already. You might want to add the global flag "g" to the regular expression though, in case there are more than one characters to replace. – Carsten Massmann Nov 28 '20 at 19:55

0 Answers0