This question already has answers here:
Unicode characters string
(5 answers)
Closed 6 years ago.
is it possible to convert a string like "\u00e8" (Got it by reading a WebRequestResponse with Streamreader) to it's unicode char(è)?
Tried many things with Encoding, but nothing works.
You can use Regex.Unescape(), which unescapes any escape sequences that are valid for a Regex (including \uXXXX). Note that it also unescapes other sequences like \t, \n, and \[.
Related
This question already has answers here:
Detecting *all* emojis
(4 answers)
Unicode character range not being consumed by Regex
(3 answers)
Closed 3 years ago.
I'm using this statement to remove emoticons from a string:
text = Regex.Replace(text, #"[^\u1F600-\u1F64F]+", ""); //Emoticons
Based on the official Unicode page chart, https://www.unicode.org/charts/PDF/U1F600.pdf.
But this replace statement not only remove emoticons also removes another characters like "." or "-".
Why is that?
This question already has answers here:
Can I expand a string that contains C# literal expressions at runtime
(5 answers)
Closed 3 years ago.
I'm implementing a compiler, and I need to convert from an escape character literal written in source code file to an actual value.
For example I might have a line of source code char = '\\'. I then parse that and get given the string "'\\'", which I need to turn into the actual char '\\'.
char.Parse and char.TryParse both fail when parsing a char in escape sequence form. For example:
char.Parse(#"\\");
Will throw "String must be exactly one character long."
Is there any way to parse everything on this list as a char (ignoring those that are to big to fit in a UTF16 char).
the # makes it a verbatim string literal. drop that and \ will be treated as the escape char for the next \.
#"\\".Length // 2
"\\".Length // 1
This question already has answers here:
C# Regex Match whole word, with special characters
(2 answers)
Regex whitespace word boundary
(3 answers)
Closed 4 years ago.
I am trying to search 100$ through the RegEx. But unable to find its pattern is as above.
\b100\$\b
However, if the text contains 100$1 then it displays properly.
But I want to do exact search.
Word boundaries only work with word characters, not $. Try using this regex:
\b100\$(?=\s|\$)
This will match 100$, where what follows the $ is either whitespace or the end of the line.
Demo
This question already has answers here:
Regular expression to match numbers with or without commas and decimals in text
(11 answers)
Closed 5 years ago.
How do I restrict special characters and character in a Textbox?
I'm using this code but I am not restricting special characters and character
code :-
if (!Regex.IsMatch(((Windows.UI.Xaml.Controls.TextBox)sender).Text, #"^\\d*\\.?\\d*$"))
{
// Write Code
}
if you're using # in front of string, you don't have to escape characters. So, remove all those extra backslash chars and your regex should work. Like this:
if (!Regex.IsMatch(((Windows.UI.Xaml.Controls.TextBox)sender).Text, #"^\d*\.?\d*$"))
EDIT:
use sites like this to test your regex.
This question already has answers here:
How do I remove diacritics (accents) from a string in .NET?
(22 answers)
Closed 9 years ago.
I have string with Unicode character, example Hãy đợi đấy.
I need an (ASCII) output Hay doi day.
How can I remove the accents?
You need a library like UnidecodeSharpFork to do that.