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

  • Home
  • SEARCH
  • 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 3286652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:24:16+00:00 2026-05-17T20:24:16+00:00

In a string, replace every occurrence of <0xYZ> with the character of hex value

  • 0

In a string, replace every occurrence of <0xYZ> with the character of hex value YZ. The < and > characters will be used only for that purpose, the string is guaranteed to be well formatted.

Example (‘0’ = 0x30): A<0x30>B => A0B

It’s an easy task, but there are many solutions and I was wondering about the best way to do it.

  • 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-17T20:24:17+00:00Added an answer on May 17, 2026 at 8:24 pm

    I think that a regular expression replace is the easiest way:

    s = Regex.Replace(
      s,
      @"<0[Xx]([\dA-Fa-f]{2})>",
      m => ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString()
    );
    

    By matching an exact pattern it places less restrictions on the string, for example that the < and > characters can still be used. Also, if a tag would happen to be malfomed, it will simply be left unchaged instead of causing an exception.

    This will replace tags like <0X4A> and <0x4a>, but leave for example <0x04a> unchanged.

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

Sidebar

Related Questions

I want to replace every character that isn't i in the string aeiou with
I am trying to replace the nth occurrence of a character or string regardless
I am trying to replace every character from a string with it's opposite but
I'm trying to write a method that does the following: Replace every occurrence of
How do I replace every occurrence of a string with another string below my
I am trying to find every occurrence of an ASCII character in a string
I have a string and I want to replace every capital 'I' with small
I want to replace every ../ and script/uploaded in my string variable to !
String contains a bunch of useful methods such as String.replace(CharSequence, CharSequence) that are completely
I want to do a string replace in Python, but only do the first

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.