I'm trying to insert trailing spaces into a VARCHAR(50) column and the SQL insert seems to be cutting them off. Here's my code:
create table #temp (field varchar(10));
insert into #temp select ' ';
select LEN(field) from #temp;
Unfortunately, this returns a length of zero, meaning the ' ' was inserted as a ''. I need a blank space to ...
I am attempting to send an e-mail in PHP and the system is rejecting the e-mail because the name portion of the e-mail address contains a period like below:
Mr. Joe Nobody <[email protected]>
I am looking for an elegant solution to replace all periods that are not part of the e-mail address with either a space or no character at...
#define STRLEN 65
/*Create linked list */
struct node {
char str[STRLEN];
struct node *next;
};
newInput = malloc(sizeof(struct node));
strcpy(newStr, newInput->str);
I left the other parts of the code, but it doesnt seem to be copying the string into newInput->str.
The string accepted is only 64 bytes.
It's just blank when...
How do I modify a single character in a string, in Python? Something like:
a = "hello"
a[2] = "m"
'str' object does not support item assignment.
...
How do I split up a string into several parts of a number of words in python. For example, turn a 10,000 word string into ten 1,000 word strings. Thanks.
...
string.split() returns a list instance. Is there a version that returns a generator instead? Are there any reasons against having a generator version?
...
I need to know if all characters in a string are equal (formed by the same character). the function must return true or false depending if all the elements of the string are equal to an particular char.
I wrote this function that works well, but I'm looking for a more optimal (fastest) solution, the strings can have thousands of chars...
I need to replace some string in a PHP code to make it look better. What would be the best way to go about that?
...
I don't know the slightest bit of Perl and have to fix a bug in a Perl script.
Given a variable $myvar which contains a string, if the first character is a dot, replace it with "foo/bar".
How can I do this?
(Bonus points if you can guess the bug)
...
Scala offers a method called stripMargin that removes the left-hand part of a multiline string up to a specified delimiter (default: "|"). Here is an example:
"""|Foo
|Bar""".stripMargin
returns the string
Foo
Bar
Is there a similar function in Clojure? If not, how would you implement it (most functionally)?
Thanks.
UPDATE: Th...
I try to capitalize the first letter in a CSV which is sorted like this:
a23;asd23;sdg3
What i want is a output like this
a23;Asd23;Sdg3
So the first String should be as is, but the second and third should have a capitalized first letter. I tried with AWK and SED but i didn't find the right solution. Can someone help?
...
So I have a string "NEW".
What is the SIMPLEST way to convert that string to "New".
Basically right now I'm doing this:
Case "NEW"
makes = connector.GetMakesByYear(_AuthorizationKey, "NewCar", CDate(Now), Year)
Case "USED"
makes = connector.GetMakesByYear(_AuthorizationKey, "UsedCar", CDate(Now), Year)
And I would prefer not...
I have any sequence (or sentence) and i want to extract the last 2 strings.
For example,
sdfsdfds sdfs dfsd fgsd 3 dsfds should produce: 3 dsfds
sdfsd (dfgdg)gfdg fg 6 gg should produce: 6 gg
...
Hello,
I have a problem where I am trying to search for a substring in string. That sub string may or may not be in the string.
str = "hello how are you?"
substr = "how are"
Two ways which I know if can be done are:
1. string.indexOf("how are")
2. regex
But, is there any other "optimized" way? What would have you done?
Can ruby pr...
This is probably a very simple question for some, but it has me stumped. Can you use variables within python's triple-quotes?
In the following example, how do use variables in the text:
wash_clothes = 'tuesdays'
clean_dishes = 'never'
mystring =""" I like to wash clothes on %wash_clothes
I like to clean dishes %clean_dishes
"""
pri...
Hello,
string DelStr = "I! am! bored!";
string RepStr = "10/07/10"
I want to delete all '!' on DelStr and I want to replace all '/' with '-' on the RepStr string.
Is there any way to do this without doing a loop to go through each character?
...
Using T-SQL, I'm trying to find the easiest way to make:
"abc.def.ghi/jkl" become "abc/def/ghi.jkl"?
Basically switch the . and /
Thank you
...
As a learning exercise, my three functions—ToggleCase, LowerCase and UpperCase—each expect a pointer to an ASCII char string, terminated by the null character; they work as expected. Are there more efficient or faster methods of accomplishing this task? Am I breaking any unspoken rules of good C coding? I've made use of macros because...
I am trying to split a string into an array of word pairs in PHP. So for example if you have the input string:
"split this string into word pairs please"
the output array should look like
Array (
[0] => split this
[1] => this string
[2] => string into
[3] => into word
[4] => word pairs
[5] => pairs please
...
I am learning regex (http://www.regular-expressions.info/), and trying to figure out how to match the part of the following string that is not: a word containing a q that is not followed by a u.
I've gotten this far, but cannot figure out how to reverse it properly. This regex is successful in finding the word. Now, I just need to figur...