Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7599695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:43:34+00:00 2026-05-30T22:43:34+00:00

How do I replace a Unicode numeral subscript or superscript (eg, ₂ ) with

  • 0

How do I replace a Unicode numeral subscript or superscript (eg, ₂) with the corresponding numeral (ie, 2) using regular expressions? I can of course replace each of them separately, but that is ten lines of code…

I am implementing this in Perl but that should not really matter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:43:35+00:00Added an answer on May 30, 2026 at 10:43 pm

    Here from the unisupers script is a Perl function to convert to Unicode superscripts:

    sub convert_to_superscripts (_) {
       my $string = $_[0];
       $string =~ tr[+−=()0123456789AaÆᴂɐɑɒBbcɕDdðEeƎəɛɜɜfGgɡɣhHɦIiɪɨᵻɩjJʝɟKklLʟᶅɭMmɱNnɴɲɳŋOoɔᴖᴗɵȢPpɸrRɹɻʁsʂʃTtƫUuᴜᴝʉɥɯɰʊvVʋʌwWxyzʐʑʒꝯᴥβγδθφχнნʕⵡ]
                    [⁺⁻⁼⁽⁾⁰¹²³⁴⁵⁶⁷⁸⁹ᴬᵃᴭᵆᵄᵅᶛᴮᵇᶜᶝᴰᵈᶞᴱᵉᴲᵊᵋᶟᵌᶠᴳᵍᶢˠʰᴴʱᴵⁱᶦᶤᶧᶥʲᴶᶨᶡᴷᵏˡᴸᶫᶪᶩᴹᵐᶬᴺⁿᶰᶮᶯᵑᴼᵒᵓᵔᵕᶱᴽᴾᵖᶲʳᴿʴʵʶˢᶳᶴᵀᵗᶵᵁᵘᶸᵙᶶᶣᵚᶭᶷᵛⱽᶹᶺʷᵂˣʸᶻᶼᶽᶾꝰᵜᵝᵞᵟᶿᵠᵡᵸჼˤⵯ];
       return $string;
    }
    

    And from the unisubs script is one for subscripts:

    sub convert_to_subscripts (_) {
       my $string = $_[0];
       $string =~ tr[+−=()0123456789aeəhijklmnoprstuvxβγρφχ]
                    [₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₔₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ];
       return $string;
    }
    

    You just have to go the other way.

    Another and simpler approach is simply to use the k-compat normalizations, which just return the base characters instead of their upper/lower versions. I haven’t checked these to see that they are all the inverses of the functions above. You can play with them using the nfkd and
    nfkc scripts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some people using look-alike Unicode symbols to replace English characters to test the internationalization,
How to replace unicode values using re in Python ? I'm looking for something
How can I replace HTML-entities in unicode-Strings with proper unicode? u'"HAUS Kleider" - Über
I want to replace these chars [^a-zа-з0-9_] with null, but I can't do it
How can I replace non-ascii chars from a unicode string in Python? This are
How can I replace lone instances of \n with \r\n (LF alone with CRLF)
I am looking to replace from a large document all high unicode characters, such
Content people have been using Word and pasting things into the old unicode system.
WHat will be the best practice to replace Unicode character in URL. For example
I have the following regex: foo = Regex.Replace(foo, @[^a-zA-Z0-9\s-], ); Currently, this removes Unicode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.