Reputation: 11
I want to check if or not a string has superscript characters. I am actually reading a pdf file, and I want to check whether the read string has some superscript characters in it.
Upvotes: 0
Views: 1557
Reputation: 10414
If the superscripts and subscripts are done with Unicode rather than PDF markup, most of the codepoints you want are likely in the block \u2070
-\u2090
, plus a couple of extras:
var subscripts = /[\u2070-\u209F\u00B2\u00B3\u00B9]/;
var target = "foo¹";
target.match(subscripts);
output:
[ '¹', index: 3, input: 'foo¹' ]
Upvotes: 2