string-manipulation

str_ireplace() not accutally removing the 'needles'

I'm using str_ireplace() to remove instances of strings in an array, and I'm returning the number of counted occurances, but it's not actually performing the replace. //replace occurances of insert, update, delete, select $dmlArray = array('select', 'update', 'delete', 'insert'); str_ireplace($dmlArray,'-- replaced DML -- ',$clean['com...

String Manipulation in Objective-C

Gotten a hold on how to fetch and write to variables in Objective-C, now it's time to learn how to do something more useful with them! Right now, I'm primarily trying to figure out how string manipulation works. In particular, I'm looking for the following functions: Concatenation Finding the length of a string (especially multi-byte...

Octal to sign in string from array

Hi I want to convert octal sign like \46 to normal sign like &. The problem is that the input is created with preg_match_all(), put into an array and then retrieved. If I'd manually input the \46 octal notation into variable with double quotes, like $input="\046"; then PHP would convert it nicely. But when I have it into an array fr...

SQL to standardize/clean up First/Middle/Last name fields

I'm writing a function in SQL that we can use to validate First/Middle/Last names we have in a given table. At the moment I'm working on a list of ascii codes for characters that I'm going to consider invalid and strip out of the input. My plan is to create a table which contains the character codes of those characters I consider to be...

Word by word comparison of two strings

Hello, I need to do Word by word comparison of two strings. Something like diff, but for words, not for lines. Like it is done in wikipedia http://en.wikipedia.org/w/index.php?title=Horapollo&action=historysubmit&diff=21895647&oldid=21893459 In result I want return the two arrays of indexes of words, which are different i...

Remove Bracketed text from String using Regex & PHP

Hi, I'm trying to write a simple php function that will strip everything between two brackets within a string. Here is what a typical string will look like: [img_assist|nid=332|title=|desc=|link=none|align=left|width=70|height=61] On November 14, Katherine Grove participated in Tulane University's School of Architecture Continuing Edu...

How to treat a returned/stored string like a raw string in Python?

I am trying to .split() a hex string i.e. '\xff\x00' to get a list i.e. ['ff', '00'] This works if I split on a raw string literal i.e. r'\xff\x00' using .split('\\x') but not if I split on a hex string stored in a variable or returned from a function (which I presume is not a raw string) How do I convert or at least 'cast' a stored/r...

Java parseFloat seems to be acting inconsistently

I am sure this has more to do with my understanding of the behaviour than any inconsistent action on the part of parseFloat, but bear with me... if I have input in the format "IDCODE: (3.5)" where IDCODE may be a few different predefined strings, and there is guaranteed to always be brackets, and there is also guaranteed to be a number ...

Removing leading and trailing spaces from a string

How to remove spaces from a string object in C++. For example, how to remove leading and trailing spaces from the below string object. //Original string: " This is a sample string " //Desired string: "This is a sample string" The string class, as far as I know, doesn't provide any methods to remove leading...

Python Remove last 3 characters of a string

I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use rstrip, I also need to remove any white space and convert to upper-case an example would be: foo = "Bs12 3ab" foo.replace(" ", "").rstrip(foo[-3:]).upper() This works and gives me BS12 which is what I want, howeve...

C tokenize polynomial coefficients

I'm trying to put the coefficients of polynomials from a char array into an int array I have this: char string[] = "-4x^0 + x^1 + 4x^3 - 3x^4"; and can tokenize it by the space into -4x^0 x^1 4x^3 3x^4 So I am trying to get: -4, 1, 4, 3 into an int array int *coefficient; coefficient = new int[counter]; p = strtok(copy, " +"); ...

convert comma separated string to list using linq

I have 3 comma separated strings FirstName, MiddleInitial, LastName I have a class NameDetails: public class NameDetails { public string FirstName { get; set; } public string MiddleInitial { get; set; } public string LastName { get; set; } } I have the values for strings as: FirstName ="John1, John2, John3" MiddleInitial...

Removing new line characters from NSString

I Have String like this Hello World of Twitter Lets See this > I want to transform it to:: Hello World of Twitter Lets See this > How should i perform such activity.on iPhone ...

How can I parse the following Array?

I have this array which gets the last table from a database. However the index contains an object and not just a string. I need to implement some string manipulation from below to get only the part table15 Array ( [0] => stdClass Object ( [table_name] => table15 [create_time] => 2009-11-24 13:10:04 ) ) ...

Lua string.format options

This may seem like a stupid question, but what are the symbols used for string replacement in string.format? can someone point me to a simple example of how to use it? ...

Blackberry - How to do text wrapping in ListField with Checkboxes?

Hi all, I m creating a ListField with Checkboxes from How To - Create a ListField with check boxes But I m not getting how to wrap Text in a row in that ListField. I referred the thread Text Wrapping for text in List Field items Here its written as If all you are displaying is text, then I would go with the approach suggested by...

Simple way to convert a string to a dictionary

What is the simplest way to convert a string of keyword=values to a dictionary, for example the following string: name="John Smith", age=34, height=173.2, location="US", avatar=":,=)" to the following python dictionary: {'name':'John Smith', 'age':34, 'height':173.2, 'location':'US', 'avatar':':,=)'} The 'avatar' key is just to sho...

how do i get an always changing value from a string c#

I am working on a program that will automatically get your characters stats and whatnot from the wow armory. I already have the html, and i can identify where the string is, but i need to get the "this.effective" value, which in this case is 594. But since its always changing (and so are the other values, i cant just take it a certain po...

problem in linq with comma separation of string

I am using the following to convert comma separated string to list. string productId ="1,2"; string productName = "Product1,Product2"; string prodCat = "Cat1,Cat1"; string quantity = "10,10"; string retailPrice = "12,12"; var _productId = new List<String>(productId.Trim().Split(',')); var _productName = new List<String>(productName.Tri...

tokenize a string keeping delimiters in Python

Hi, Is there any equivalent to str.split in Python that also returns the delimiters? I need to preserve the whitespace layout for my output after processing some of the tokens. Example: >>> s="\tthis is an example" >>> print s.split() ['this', 'is', 'an', 'example'] >>> print what_I_want(s) ['\t', 'this', ' ', 'is', ' ', 'an', ' '...