string-manipulation

Rewrite URL-string with String.replace in Actionscript 3

Hello, I'm getting a string that looks like this from a database: ~\Uploads\Tree.jpg And I would like to change it in Actionscript3 to Uploads/Tree.jpg Any idea how I can do this in neat way? ...

Checking a string to see if a specific grouping exist (PHP)?

situation: A user inputs a user name and password. now the user enters a user name called Game_Admin. Thus tries to imitate being a head power of the site and scam others. At the moment My log in script check for Length Characteristics, and to see if it already exist. My question how do I go about checking to see if a player enters a sp...

What is the best way to strip out all html tags from a string?

Using PHP, given a string such as: this is a <strong>string</strong>; I need a function to strip out ALL html tags so that the output is: this is a string. Any ideas? Thanks in advance. ...

C Golf: # spaces in string

I'm trying to come up with with shortest C function (including spaces, any macros that are substituted into it) possible that is passed a NULL-terminated string and returns the number of spaces in that string. This is what I've got so far: int n(char*l){return*l?!(*l-32)+n(++l):0;} Which is 42 characters long. Any improvements? ...

C++: Looking for a concise solution to replace a set of characters in a std::string with a specific character

Suppose I have the following: std::string some_string = "2009-06-27 17:44:59.027"; The question is: Give code that will replace all instances of "-" and ":" in some_string with a space i.e. " " I'm looking for a simple one liner (if at all possible) Boost can be used. ...

PHP's gzuncompress function in Java?

I'm compressing a string using PHP's gzcompress() function: http://us2.php.net/manual/en/function.gzcompress.php I'd like to take the output from the PHP compression function and decompress the string in Java. Can anyone send me down the right path? Thanks so much! ...

Given the string "268179", is there any built in methods that could change this to 2.68 in C#

Looking to convert this to a string value of 2.68. I have a way to parse it out but was wondering if there was some built in functionality in the framework to do this. ...

What is the Visual Basic (VB) equivalent of \ in C#?

In C# you can use \ to ignore the special characters: string myString = "this is a \" string"; that would work as one complete string... in VB, doing that does not work... Anyone know the equivalent of \ to ignore special characters for VB? ...

Renaming files in MATLAB

I'm trying to programmatically rename a file in the working directory from a = 'temp.txt' to b = 'hello.txt'. How would you suggest doing so? Is there an easy file renaming function in MATLAB? ...

Matlab: string finding

I would like to have the original string 'black.txt' to be parsed into a = 'black' and ext = '.txt'. Every filename/string is going to have the extension '.txt'. I'm wondering what would be the easiest way of achieving this in Matlab so that I can concatenate the new string appropriately. Thanks in advance. ...

Stripping everything but alphanumeric chars from a string in Python

What is the best way to strip all non alphanumeric characters from a string, using Python? The solutions presented in the PHP variant of this question will probably work with some minor adjustments, but don't seem very 'pythonic' to me. For the record, I don't just want to strip periods and commas (and other punctuation), but also quo...

Exception when using strncpy

Hi The following code fragment ends in an exception when executing the strncpy funtion: #define MAX_FILENAME_LEN 127 typedef struct { unsigned long nameLength; char name[MAX_FILENAME_LEN + 1]; } filestructure; char *fileName; strncpy( fileName, filestructure->name, MAX_FILENAME_LEN ); *( fileName + MAX_FILENAME_LEN+1 ) = 0; Ayone ...

C# code wont compile. No implicit conversion between null and int

Possible Duplicate: Nullable types and the ternary operator. Why wont this work? Why doesn't this work? Seems like valid code. Can anyone help? string cert = ddCovCert.SelectedValue; int? x = (string.IsNullOrEmpty(cert)) ? null: int.Parse(cert); Display(x); How should I code this? The method takes a Nullable. If the dro...

How to replace multiple white spaces with one white space

Let's say I have a string such as: "Hello how are you doing?" I would like a function that turns multiple spaces into one space. So i would get: "Hello how are you doing?" I know I could use regex or call string s = "Hello how are you doing?".replace(" "," "); But I would have to call it multiple...

Embeddable language with good string manipulation support

I've been working on a C program which does quite a lot of string manipulation, and very often needs to be tweaked and recompiled for some sort of special case processing. I've been thinking that embedding some scripting language with good string manipulation support might make sense for the project. What language would provide the best...

Efficient Algorithm for String Concatenation with Overlap

We need to combine 3 columns in a database by concatenation. However, the 3 columns may contain overlapping parts and the parts should not be duplicated. For example, "a" + "b" + "c" => "abc" "abcde" + "defgh" + "ghlmn" => "abcdefghlmn" "abcdede" + "dedefgh" + "" => "abcdedefgh" "abcde" + "d" + "ghlmn" => "abcdedghlmn" "abcdef...

Regex return value between two values?

Is it possible to return a string between 2 strings, using regex? For example, if I have this string: string = "this is a :::test??? string"; Can I write a function to return the word "test" using a regex? Edit: Sorry, I'm using C# ...

Optimize code so that it executes faster.

Hi, How can I optimize the following code so that it executes faster: static void Main(string[] args) { String a = "Hello "; String b = " World! "; for (int i=0; i<20000; i++) { a = a + b; } Console.WriteLine(a); } ...

Convert String to Integer

Possible Duplicate: how can I convert String to Int ? Hi, I have the following problem converting string to an integer: string str = line.Substring(0,1); //This picks an integer at offset 0 from string 'line' So now string str contains a single integer in it. I am doing the following: int i = Convert.ToInt32(str); i shou...

MYSQL: self written string-manipulation function returns unexpected result

I'm trying to implement a MYSQL function MY_LEFT_STR(STRING x,INT position) in such a way that MY_LEFT_STR('HELLO', 4) => returns 'HELL' (same as internal LEFT function) MY_LEFT_STR('HELLO',-1) => returns 'HELL' DROP FUNCTION IF EXISTS MY_LEFT_STR; CREATE FUNCTION MY_LEFT_STR( in_str VARCHAR(255), pos INT ) RETURNS VARCHAR(255)...