I've got a string that could be in one of two forms:
prefix=key=value (which could have any characters, including '=')
or
key=value
So I need to split it either on the first or second equals sign, based on a boolean that gets set elsewhere. I'm doing this:
if ($split_on_second) {
$parts = explode('=', $str, 3);
$key = $par...
Is there an elegant way in SQL Server to find all the distinct characters in a single varchar(50) column, across all rows?
Bonus points if it can be done without cursors :)
For example, say my data contains 3 rows:
productname
-----------
product1
widget2
nicknack3
The distinct inventory of characters would be "productwigenka123"
...
Hi,
I have large file comprising ~100,000 lines. Each line corresponds to a cluster and each entry within each line is a reference i.d. for another file (protein structure in this case), e.g.
1hgn 1dju 3nmj 8kfn
9opu 7gfb
4bui
I need to read in the file as a list of lists where each line is a sublist, thus preserving the integrity o...
I want pass a parameter of javascript functiona which is a string. This javascript function is a hintbox on mousehover..
and the string i am using is like this:
Hemmed Finish: Every side/edge (1/2"
to 2") of the banner are folded and
glued (special vinyl solution) or heat
pressed. This is the most common and
best finish opt...
In python:
s = '1::3'
a = s.split(':')
print a[0] # '1' good
print a[1] # '' good
print a[2] # '3' good
How can I achieve the same effect with zsh?
The following attempt fails:
s="1::3"
a=(${(s/:/)s})
echo $a[1] # 1
echo $a[2] # 3 ?? I want an empty string, as in Python
...
Here is my attempt to solve the About.com Delphi challenge to un-camel-case a string.
unit challenge1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
check = 65..90;
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Send...
What's the cleanest way of editing the characters in a string in C#?
What's the C# equivalent of this in C++:
std::string myString = "boom";
myString[0] = "d";
...
I have a python function that gets an array called row.
Typically row contains things like:
["Hello","goodbye","green"]
And I print it with:
print "\t".join(row)
Unfortunately, sometimes it contains:
["Hello",None,"green"]
Which generates this error:
TypeError: sequence item 2: expected string or Unicode, NoneType found
Is t...
Is this the right method to reverse a string? I'm planning to use it to reverse a string like: Products X1 X3 to X3 X1 Products
I want it to be a global function which can be used elsewhere.
public static string ReverseString(string input, string separator, string outSeparator)
{
string result = String.Empty;
string[] temp =...
I am passing in command line arguments to my Lisp program and they are formatted like this when they hit my main function:
("1 1 1" "dot" "2 2 2")
I have a dot function (which takes two vectors as arguments) and would like to call it directly from the argument, but this isn't possible because something like (funcall (second args)...) r...
What is the most efficient way to split a string by a very simple separator?
Some background:
I am porting a function I wrote in C with a bunch of pointer arithmetic to java and it is incredibly slow(After some optimisation still 5* slower).
Having profiled it, it turns out a lot of that overhead is in String.split
The function in que...
Is there a built in function in PHP that would combine 2 strings into 1?
Example:
$string1 = 'abcde';
$string2 = 'cdefg';
Combine to get: abcdefg.
If the exact overlapping sequence and the position are known, then it is possible to write a code to merge them.
TIA
...
Background information: - There are nearly 7000 individuals and there is data about their performances in one, two or three tests.
Every individual has taken the 1st test (let's call it Test M). Some of those who have taken Test M have also taken Test I, and some of those who have taken Test I have also taken Test B.
For the first two ...
I guess it has to do something with string being a reference type but I dont get why simply string.Replace("X","Y") does not work?
Why do I need to do string A = stringB.Replace("X","Y")? I thought it is just a method to be done on specified instance.
EDIT: Thank you so far. I extend my question: Why does b+="FFF" work but b.Replace do...
ok I know that this should be simple... anyways say:
line = "$W5M5A,100527,142500,730301c44892fd1c,2,686.5 4,333.96,0,0,28.6,123,75,-0.4,1.4*49"
I want to strip out the spaces. I thought you would just do this
line = line.strip()
but now line is still '$W5M5A,100527,142500,730301c44892fd1c,2,686.5 4,333.96,0,0,28.6,123,75,-0.4,1....
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 need to strip the "label" off the front of strings, e.g.
note: this is a note
needs to return:
note
and
this is a note
I've produced the following code example but am having trouble with the regexes.
What code do I need in the two ???????? areas below so that I get the desired results shown in the comments?
using Sy...
-_1234d5fr
should ideally turn into
1234d5fr
Thank you so much!
...
When I am concatenating object values together to form a string in VB.NET, is there a difference in performance or a recommended best practice between using the & concat or the + concat with calls to .ToString() on each object?
Example (which is faster or best practice):
Dim result1 As String = 10 & "em"
Dim result2 As String = 10.ToSt...
I've spent half day trying to figure out this and finally I got working solution.
However, I feel like this can be done in simpler way.
I think this code is not really readable.
Problem: Find first non-repetitive character from a string.
$string = "abbcabz"
In this case, the function should output "c".
The reason I use concatenation ...