string-manipulation

Generate string with apostrophe after each letter of original string in turn.

How can I iteratively create a variant of "Murrays" that has an apostrophe after each letter? The end-result should be: "m'rrays,mu'rrays,mur'rays,murr'ays,murra'ys,murray's" ...

C# Built in way to safeguard a string for a file name

I want to know if there is some built in way in the .net framework to take ANY string, and turn it into a "safe" string that can be used as a filename? Thanks ...

should we use Path.DirectorySeperatorChar C#

A question that's lurking in my head for a while now. What's the importance of Path.DirectorySeperatorChar ? I mean can't we just put '\' instead - which i think is faster than calling a property especially if you're constructing a huge number of paths in your application? Is there a reason for it? could there be another Char for folder...

Split string on multi-char seperator and maintain seperator

Using VB.NET - I have a string: "##RES00012##Some value ##RES00034##Another value" That I want to split using the "##RES" as a seperator to: "##RES00012## Some value " and "##RES00034## Another value" The string.split function doesn't seem to offer an overload to split on multiple characters or array of characters and maintain the se...

How do I replace multiple spaces with a single space in C?

Well I'm looking for a function that reduce multiple spaces in a string. For example for string s given : s="hello__________world____!" The function must return "hello_world_!" In python we can do it via regexp simply as: re.sub("\s+", " ", s); ...

Separate firstname and lastname from fullname string in C#

I'm doing a website migration that involves extracting firstname and lastname from fullname. Given these were created by the end user, all kinds of permutations exist (although English and generally not too strange). Mostly I can take the first word as firstname and the last word as the lastname but have some exceptions from the occasi...

php email piping

Im trying to setup a program that will accept an incoming email and then break down the "sender" and "message" into php variables that i can then manipulate as needed, but im unsure where to start. I already have the email address piped to the php file in question (via cpanel) ...

"Unrolling" a string with XSL

We have an application which has a heirarchical group structure. Some of the groups are passed in this format: /Geography/NA/US/California I would like to "unroll" this string so that I can get a node set like the following: /Geography /Geography/NA /Geography/NA/US /Geography/NA/US/California I know I can use str:tokenize and get ...

TextBox Search string manipulation

This is sort of complicated for me to explain,let me try anyway. i want to know how can i manipulate the string i've collected from this(such type of ) textbox and use it for my pupose in webapp or dektop app. i mean for example, i've two situations. 1) If i've to take the search string in text box and want to forward user to say s...

NSString - Convert to pure alphabet only (i.e. remove accents+punctuation)

I'm trying to compare names without any punctuation, spaces, accents etc. At the moment I am doing the following: -(NSString*) prepareString:(NSString*)a { //remove any accents and punctuation; a=[[[NSString alloc] initWithData:[a dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding] a...

In Classic ASP, how do I insert a character into a string at a specified index?

So I have an array of indexes of characters in a string that I wish to insert a character before, how do i easily insert a character before each index? So for example: "The big brown fox ... " the positions array = 4,9 the character to insert ',' the result: "The, big, brown fox ..." Is there a method that provides such an easy util...

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("-"); }...

Regexp for validating .au domain names

Hi, I need a quick regexp for validating that a string is a valid .au domain name. For example: xxx.com.au xxx.net.au xxx.org.au xxx.biz.au xxx.--.au all of these should be considered valid. This should be pretty simple for someone not as hopeless with regexps as I am. Any ideas? ...

Extracting text fragment from a HTML body (in .NET)

I have an HTML content which is entered by user via a richtext editor so it can be almost anything (less those not supposed to be outside the body tag, no worries about "head" or doctype etc). An example of this content: <h1>Header 1</h1> <p>Some text here</p><p>Some more text here</p> <div align=right><a href="x">A link here</a></div><...

Split string in T-SQL.

How can I get the string "text." from the string "This is my text."? ...

How do you cut off text after a certain amount of characters in PHP?

I have two string that i want to limit to lets say the first 25 characters for example. Is there a way to cut off text after the 25th character and add a ... to the end of the string? So '12345678901234567890abcdefg' would turn into '12345678901234567890abcde...' where 'fg' is cut off. ...

Simple String Manipulation in VB.NET

This is probably quite a simple question, but I can't remember how to do it off hand. I have an e-mail address of "[email protected]". I want to grab the @ and everything after it and then I'll be adding a prefix to the front of the address as I go. I'm just wonderng how I get hold of the @bar.com from the string? I know I should know how ...

Generating Comma Separated Values

Suppose I have a collection of strings: "foo" "bar" "xyz" And I would like to generate a comma separated values from the list into something like: "foo, bar, xyz" Notice the lack of ", " at the end. I am aware that there are dozens of ways to generate this: use for-loop and string.Format() or StringBuilder. use integer counter a...

char[] (c lang) to string (c++ lang) conversion

I can see that almost all modern APIs are developed in the C language. There are reasons for that: processing speed, low level language, cross platform and so on. Nowadays, I program in C++ because of its Object Orientation, the use of string, the STL but, mainly because it is a better C. However when my C++ programs need to interact w...

Find length of initial segment matching mask on Arrays

Given an array with n values, for example: $arr[] = 'ABCDEFABC'; $arr[] = 'ABCDEFDEF'; $arr[] = 'ABCDEFGHI'; $arr[] = 'ABCDEFJKL'; how can I find the initial segment that matches all (or most, in the example bellow) values, in this case ABCDEF? EDIT 2: NOT SOLVED, SEE ANSWER. Even worse, given the following array: $arr[] = 'ABCDEFA...