Remove last special character if last character is question mark. First we have to check the last character in given string is question mark or not. If last character is question mark then we remove the last character.
You can remove any last specific character if it exists at last position with the help of given example using c#. This function will retrurn text without special charcter ?.
public static string RemoveLastSpecialCharcter(string text)
{
var last_character = text[text.Length - 1];
if (last_character == '?')
{
text = text.Remove(text.Length - 1);
}
return text;
}
Post your comments / questions
Recent Article
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
- How to get thumbnail from vimeo video URL in Python?
- Remove all special characters, punctuation except spaces from string - Python
- OSError: cannot write mode RGBA as JPEG- Python
- expected str, bytes or os.PathLike object, not JpegImageFile - Python
Related Article