string-manipulation

How can I mimic text-overflow: ellipsis in Firefox?

I have some dynamic text contained in a div that is set to whatever a user enters in a textbox field. If the text doesn't fit in the div, right now it just gets cut off at the edge and all the text that extends past the border is not visible. I would like to truncate the text so that it fits inside the box and has an ellipsis (...) appen...

C++ character replace

What is the best way to replace characters in a string? Specifically: "This,Is A|Test" ----> "This_Is_A_Test" I want to replace all commas, spaces, and "|" with underscores. (I have access to Boost.) ...

Strip characters from a string in Excel.

I want to strip off the last character in a string on a given cell. I was trying to use the following formula: =LEFT(A2, LEN(A2)-1) This pisses off Excel as it is a circular reference on cell A2... I'm terrible with Excel formulas... any help is greatly appreciated. Thanks. ...

Remove Characters from the end of a String Scala

What is the simplest method to remove the last character from the end of a String in Scala? I find Rubys String class has some very useful methods like chop. I would have used "oddoneoutz".headOption in Scala, but it is depreciated. I don't want to get into the overly complex: string.slice(0, string.length - 1) Please someone tell me...

compairing and splitting of string inside js function

I have a string in a variable ie; var test= "http://www.gmail.com@%@http://www.google.com@%@http://www.yahoo.com@%@"; i have this thing in my javascript function. i want to split this string from the occurences of the special characters ie: @%@ so after splitting i want to push this thing to an array like this var spcds = []; ...

Php trim string at a particular character

Hi, is there a php string function to trim a string after a particular character. I had a look on the php.net site and did a google search but couldn't find anything. The only solution i could think of was explode and then grab the first part of the array but thats not the most elegant solution. For example $sting = "/gallery/image?a...

Python Spliting a string

Hello, I looking to split a string up with python, I have read the documentation but don't fully understand how to do it, I understand that I need to have some kind of identifier in the string so that the functions can find where the string(unless I can target the first space in the sentence?) So for example how would I split "Sico87 ...

Swapping a string where space is found in php

Hi, I need to implement the following functionality: I have a name field which contains both name and surname. This is stored in a database and is in the order 'surname name'. I am implementing a script which searches through these records. Currently, I managed to check if a string contains a space, if it contains a space it means it ...

Python split value of a string

Hello, I am working on a site in Python built on the back of Django(awesome framework, cant get my head around python), I looking to split a string that is returned from a database and I want it to be split when the first space occurs so I tried something like this, {{product.name.split(' ' ,1)}} This did not work and I get this st...

Calculating context-sensitive text correlation

Suppose I want to match address records (or person names or whatever) against each other to merge records that are most likely referring to the same address. Basically, I guess I would like to calculate some kind of correlation between the text values and merge the records if this value is over a certain threshold. Example: "West Lawnm...

How to remove punctuation from a String in C

I'm looking to remove all punctuation from a string and make all uppercase letters lower case in C, any suggestions? ...

Concatenate null-terminated strings recursively

I'm inventing interview questions that require analysis of C++ code that does something simple with pointers and recursion. I tried to write strcat() in recursive manner: size_t mystrlen( const char* str ) { if( *str == 0 ) { return 0; } return 1 + mystrlen( str + 1 ); } void mystrcpy( char* to, const char* from ) {...

How can I copy only text of a specific colour in Excel?

I have a worksheet with a large number of cells containing large amounts of text. Within any particular cell there may be some text that is coloured red. I want to remove that text and copy it to a different column. I have a VBA function that does this by checking the cell contents character by character but the spreadsheet is quite lar...

How might I extract the number from a number + unit of measure string using JavaScript?

If I have this string str = "22px"; How do I extract just the number 22? Thanks. ...

String manipulation using Ardunio and C++

I am trying to manipulate a string in C++. I am working with an Arduino board so I am limited on what I can use. I am also still learning C++ (Sorry for any stupid questions) Here is what I need to do: I need to send miles per hour to a 7 segment display. So if I have a number such as 17.812345, I need to display 17.8 to the 7 s...

Replacing a string inside a string in PHP

I have strings in my application that users can send via a form, and they can optionally replace words in that string with replacements that they also specify. For example if one of my users entered this string: I am a user string and I need to be parsed. And chose to replace and with foo the resulting string should be: I am a user s...

ostringstream problem with int in c++

Hi, I would expect the following code to output hello5. Instead, it only outputs hello. It seems to be a problem with trying to output an int to the ostringstream. When I output the same directly to cout I receive the expected input. Using XCode 3.2 on Snow Leopard. Thanks! #include <iostream> #include <string> #include <sstream> usi...

jQuery .search() to any string

I saw this code snippet: $("ul li").text().search(new RegExp("sometext", "i")); and wanted to know if this can be extended to any string? I want to accomplish the following, but it dosen't work: $("li").attr("title").search(new RegExp("sometext", "i")); Also, anyone have a link to the jQuery documentation for this function? I fail...

How do I "add" strings in PHP - not concatenate, but "add" them. (as if each character was a base 36 numbers)

Unfortunately I inherited some code (c/c++) that does some string manipulation and now I need to copy/port that over to php so this functionality can be accessed over the internets. Specifically the functionality takes some arbitrary strings and "adds" them together. (the c code iterates down the character array and then does some ch...

C++ Overloading the >> operator

I need to overload the stream extraction operator. I need to do this by allowing a user to input a string of characters at a prompt, say "iamastring", and then the operator would extract each character from the string and test whether or not it is whitespace and if it is not whitespace store it in a character array which is then passed ...