I’m trying to input a control character from an asp.net form. For example I want a user to be able to enter \t into a text box and it be \t not \ \t (The space is there as one of them gets escaped if I put them together). What’s the best way to go with this? I’ve been staring at it continuously now for quite a while and the answer isn’t jumping out at me. Thanks.
Update:
Thanks guys, but I’ve just answered myself.
I’ve just found in Regex the static Unescape method, so in my web app I am now doing:
(Where tb is an asp.net TextBox)
var inputText = tb.Text;
if (inputText.Length == 2)
{
var escaped = System.Text.RegularExpressions.Regex.Unescape(inputText);
if (escaped.Length == 1)
{
var character = escaped.ToCharArray()[0];
if (char.IsControl(character))
{
inputText = character.ToString();
}
}
}
Thanks guys, but I’ve just answered myself.
I’ve just found in Regex the static Unescape method, so in my web app I am now doing:
(Where tb is an asp.net T