string

Save loop result to a string

Hi everyone! Is it possible to save loop results to a string? $sql = "SELECT SUBSTR(a.`title`, 1,1) FROM articles a WHERE a.`tag` = 'human_resources'"; $results = db_query($sql); while ($fields = db_fetch_array($results)) { foreach($fields as $key => $value) { echo $value; } } The code above outputs titles of art...

What is the fastest way to join Dictionary<string,string> into querystring?

I have following data: Dictionary<string,string> dctParameters = new Dictionary(){ {"a",var1},{"b",var2},{"c",var3},.... } I want to join the "dctParameters" into a querystring. What's the fastest / best among the following ways? Can you think you of a better way to do this? 1st method: StringBuilder data = new StringBuilder(); st...

Hash function for short strings

I want to send function names from a weak embedded system to the host computer for debugging purpose. Since the two are connected by RS232, which is short on bandwidth, I don't want to send the function's name literally. There are some 15 chars long function names, and I sometimes want to send those names at a pretty high rate. The solu...

C# string duplication issue

Hello everyone, I am using VSTS 2008 + C# + .Net 3.0. I have two input strings, I think they are different. But the following C# code thinks they are the same, and throws System.Data.ConstraintException, says Column Name is contrained to be unique, but value already exists. Any ideas what is wrong? Here is my code and my input strings,...

Java: Comparing two string arrays and removing elements that exist in both arrays.

Hello all, This is mainly a performance questions. I have a master list of all users existing in a String array AllUids. I also have a list of all end dated users existing in a String array EndUids. I am working in Java and my goal is to remove any users that exist in the end dated array from the master list AllUids. I know PHP has a f...

utterly weird behavior in basic string comparison

hi there, this doesn't make any sense to me. must be wrong or painfully obvious. after slicing and dicing, i got 2 vars with the following values in vb.net: strTag = "&lt;#<span class=SpellE>vermittler_person_Name</span>&gt;" tmp = "&lt;#<span class=SpellE>vermittler_person_Name</span>&gt;" comparing the vars gives a false: strT...

C# ChangeType and ToString?

I want to Convert an int to a specific type and then return a string whose format depends on the type I converted it to. I have a property that returns a Type object, and another that I want to return a string whose format depends on the Type. Why doesn't the compiler like the code in HexString below? Is there another equally brief way...

Simple way to repeat a String in java

I'm looking for a simple commons method or operator that allows me to repeat some String n times. I know I could write this using a for loop, but I wish to avoid for loops whenever necessary and a simple direct method should exist somewhere. String str = "abc"; String repeated = str.repeat(3); repeated.equals("abcabcabc"); Related to...

AS2 String Replace for Array of Characters?

I have a function that works great in Actionscript 2, except it can only replace one character. I need it to behave more like str_replace in PHP and replace an array of characters. Here is the code I have now, it simply replaces a space ( ) with a hyphen (-) in a String. function str_replace(str){ return str.split(" ").join("-"); }...

Bash string comparison syntax

I was looking through the /etc/bash_completion script found in some Debian packages. I was interested in using the code that looks through a specific directory (/etc/bash_completion.d/ by default) and sources every file in that directory. Unfortunately, trying to run the script causes errors under the Mac OS X version of bash. The line...

PHP stripping strings..

Hi all, I would like to strip everything in a string before a - and leave what's after that. For example: 15.11-101 I want to strip 15.11 and leave 101. I've tried a few different things, but can't seem to get it working, if anyone could help me out, that'd be fantastic :) Cheers Leanne ...

Php error log shortens strings

I read call stack in Magento, but they are unreadable due to string shortage, eg: include('/var/www/oneste...') How can I see full string, in this case full path? ...

What function is meant to format/substitute {0} {1} parameters in an string in Grails/Groovy?

I'm just getting started with Groovy/Grails I noticed the error messages you get when you validate a form look like this: Property [{0}] of class [{1}] cannot be blank For example this code to dump the errors to the console s.errors.allErrors.each { println it.defaultMessage } Now, it.arguments ...

What does % do to strings in Python?

I have failed to find documentation for the operator % as it is used on strings in Python. Does someone know where that documentation is? ...

C#: Remove the spacing at the edges inside a button.

Hi guys! Situation: I need a tiny button, with some text on it. Problem: The button seems to think displaying empty space near its edges is more important than displaying my Text. I can't for the life of me figure out how to remove that blank stuff at the edges. Any help is greatly appreciated! Thanks in advance. -MonsterMaw ...

How do I strip bad chars from a string in JS?

My JS saves some string data to JSON using "stringify()", but observing the outputted JSON string I see a lot of strange chars (out of keyspace), such as NULLs and other bad chars. Now I don't have a list of these "bad" chars so how can I strip them out of my string data? ...

Regex to search for a word in a string in Visual Studio

I need to search all of my codebase for "Url" and replace it with "URL". If I search for Url in Visual Studio I also get all my variables with "Url" in it. Anyone have a Regex I can use to only find Url within a quoted string e.g. "Use this Url:"? Edit I was looking looking for a quick and dirty way to find designer text and hard cod...

storage of user, error, exception messages (c++)

Hello everyone. Rather simple question. Where should I store error,exception, user messages? By far, I always declared local strings inside the function where it is going to be invoked and did not bother. e.g. SomeClass::function1(...) { std::string str1("message1"); std::string str2("message2"); std::string str3("message3"); ... // so...

PHP multiline, concatenated strings

Any difference between the two, int terms of speed/performance? $sql = "SELECT * " . "FROM `myTable` " . "WHERE `id` = 4"; $sql = "SELECT * FROM `myTable` WHERE `id` = 4"; ...

Java Data Types: String and Array

Hello, I've been going through Sun Microsystem's Java Tutorial and got some questions while reading the following: I/O from the Command Line: The Console Object "Second, readPassword returns a character array, not a String, so the password can be overwritten, removing it from memory as soon as it is no longer needed." My questions ar...