I want to remove all special characters from a string. Allowed characters are A-Z (uppercase or lowercase), numbers (0-9), underscore (_), or the dot sign (.).
I have the following, it works but I suspect (I know!) it's not very efficient:
public static string RemoveSpecialCharacters(string str)
{
StringBuilder sb = new…
I have an Entity class, which contains 3 pointers: m_rigidBody, m_entity, and m_parent. Somewhere in Entity::setModel(std::string model), it's crashing. Apparently, this is caused by bad data in m_entity. The weird thing is that I nulled it in the constructor and haven't touched it since then. I debugged it and put a watchpoint on it,…
I have a string that looks a little like this, world:region:bash
It divides folder names, so i can create a path for FTP functions.
However, i need at some points to be able to remove the last part of the string, so, for example
I have this world:region:bash
I need to get this world:region
The script wont be able to know what the…
This thing is really wracking my mind. I'm learning C++ and I wanted to define a constant that I can use in another function, A short answer on how to do this will be fine..
Lets say at the beginning of my code I want to define this constant:
//After #includes
bool OS = 1; //1 = linux
if (OS) {
const ??? = "clear";
} else {
…
I'm using OleDbDataReader rdr to read a "Comments" field in BLOB form (sub_type 1 segment size 80) into a string from an Interbase DB, and I keep getting exceptions. Any suggestions?
Attempt #1
ls_Chap_Comments.Add((rdr["Comments"]).ToString());
InvalidCastException: The data value could not be converted for reasons other…
Hi im having a few problems rotating a string, i found that you need graphics.rotate() but when i change the rotation, i cannot even see the string. It appears the pivot point has completely thrown me. Also i saw an example with transform but i decided i did not need this?
If my string was a graph label, reading top to…
I need to parse the following string data and convert it into the specified C# class object.
Please suggest me a solution for this:
Input string: A||B||C
Output: Class containing a list of 3 objects of type string i.e A, B, C
Input String: A||{a1||a2||a3}||B||C
Output: Class containing a list of 3 elements i.e A, B, C…
So I have a string, and I want to strip out some parts of it using, for example, the firt and last characters of the "interesting" part.
String dirty = "$!$!%!%$something interesting&!!$!%$something interesting2";
And the output something like:
String clean = "something interesting:something interesting2";
…
I have a large piece of text in which there is something simular to this:
!#_KT_#!COMMANDHERE!#_KT_#!
I want, in VB.Net, to get the 'COMMANDHERE' part of the string, how would I go about doing this? I have this so far:
Dim temp As String = WebBrowser1.Document.Body.ToString
Dim startIndex As Integer =…
This question might be asked before but I couldn't find exactly what I need.
My problem is, I have a buffer loaded by data downloaded from a webservice. The buffer is in unsigned char* form in which there is no '\0' at the end. Then I have a poco xml parser needs a string.
I tried assigning it to…
I want to make a program that will read some number in string format and output it like this: if the number is 12345 it should then output 12 23 34 45 . I tried using the substr() function from the c++ string library, but it gives me strange results - it outputs 1 23 345 45 instead of the expected…
I am not good in regular expressions and I need help in replacing the string.
String str = "Name_XYZ_";
str = "XYZ_NAME_";
So how can I replace "Name_" or "_NAME_" from above two strings with empty string?
The conditions are "Name" can be in any case and it can be at index 0 or at any…
Probably this is not a difficult question, but I am always a little bit confused on how to treat String type as an argument in Visual C++. I have the following to functions:
void function_1(String ^str_1)
{
str_1 = gcnew String("Test");
}
void function_2()
{
String ^str_2 = nullptr;
…
I am trying to convert a string into datetime with the following C# code,
DateTime dTo = DateTime.ParseExact(dateTo, "mm/dd/yyyy", CultureInfo.InvariantCulture);
eachtime I pass dateTo as 1/1/2010 it fails, instead it needs the string to be 01/01/2010.
What string format should I use…
This is sort of the Java analogue of this question about C#.
Suppose I have a String object which I want to represent in code and I want to produce a string literal that maps to the same thing.
I was just about to write a state machine that ingests the string character by character and…
I have this code:
Dim birthdaystring As String = MonthBirth.SelectedValue.ToString & "/" & DayBirth.SelectedValue.ToString & "/" & YearBirth.SelectedValue.ToString
Dim birthday As DateTime = Convert.ToDateTime(birthdaystring)
Which produces errors (String was not…
Hello,
I am looking for the fastest way to remove duplicate values in a string separated by commas.
So my string looks like this;
$str = 'one,two,one,five,seven,bag,tea';
I can do it be exploding the string to values and then compare, but I think it will be slow. what about…
Guys, help me clarify.
Say i have the following line in my program:
jobSetupErrors.append("abc");
In the case above where jobSetupErrors is a StringBuilder(), what i see happen is:
New String Object is created and assigned value "abc"
value of that String object is…
If I have a string
"this is a string"
How can I shorten it so that I only have one space between the words rather than multiple? (The number of white spaces is random)
"this is a string"
I am trying to split a string using spaces as a delimiter. I would like to store each token in an array or vector.
I have tried.
string tempInput;
cin >> tempInput;
string input[5];
stringstream ss(tempInput); // Insert the string into a stream
…
Hello, I want to determine if a string is the name of a month and I want to do it relatively quickly. The function that is currently stuck in my brain is something like:
boolean isaMonth( String str ) {
String[] months = DateFormatSymbols.getInstance().getMonths();
…
I am having a problem figuring how to check a string for the same characters in a row then count that same character in a row then printing it out then giving the location of the last occorance of that character count then printing it out then moving to the next…
Hi guys
I need to convert a string to a monetary format of {###}.###.###,##
that is
a value of 5461497702600
would become
54.614.977.026,00
The numbers become excessively large.
I am using
return string.Format(string.Format("{0:#" + (val < 1000 ? ""…