64
1
using System;
2
using System.Globalization;
3
using System.Text.RegularExpressions;
4
5
public static class Program
6
{
7
const string strRegGetHexNumber = @"\\u[0-9a-f]{2,}|0x[0-9a-f]{2,}|%[0-9a-f]{2,}|\u0023([0-9a-f]){1,6}|&\u0023x([0-9a-f]){1,6};|\s[0-9a-f]{2,}|[0-9a-f]{2,}|[«‹»›„‚“‟‘‛”’""""❛❜❝❞〝〞〟"""""'‘][0-9a-f]{2,}[’'""""«‹»›„‚“‟‘‛”’""""❛❜❝❞〝〞〟"]";
8
private static readonly Regex rgxGetHex = new Regex(strRegGetHexNumber, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
9
public static void Main()
10
{
11
string unicodeText = "UTF-16 (hex) 0x0023 (0023)";
12
//https://en.wikipedia.org/wiki/Hexadecimal --remove possible prefixes
13
string prefixfree = string.Empty;
14
string[] prefixHexs = new string[]{"0x", "\\u", "#", "&#", "\\x", "\\s", "U+", "X'", "16#", "#x", "#16r", "&H", "0h"};
15
foreach (var pre in prefixHexs)
16
{
17
if (unicodeText.IndexOf(pre) > -1)
18
{
19
prefixfree = unicodeText.Substring(unicodeText.IndexOf(pre) + pre.Length);
20
break;
21
}
22
}
23
24
if (string.IsNullOrEmpty(prefixfree))
Cached Result