string-manipulation

TSQL CASE WHEN THEN SYNTAX - USING REPLACE

Hi there, This actually applies to a prior question, TSQL 2008 USING LTRIM(RTRIM and Still Have Spaces I am at the point of writing a very lengthy SELECT statement using OMG PONIES statement to remove NON NULL non visible characters (WHEN PropStreetAddr is NOT NULL THEN (SELECT LTRIM(RTRIM((REPLACE(PropStreetAddr, ...

Replace string only once with php preg_replace

Hello, I need a replace string once function and believe preg_match might be my best bet. I was using this, but due to the dynamicness of use, sometimes this function behaves strangely: function str_replace_once($remove , $replace , $string) { $pos = strpos($string, $remove); if ($pos === false) { // Nothing found ...

iPhone Objective-C: If string contains...?

How can I tell if a string contains something? Something like: if([someTextField.text containsString:@"hello"]) { } ...

Replace same character several times with different string

Hello, I have a string with the same character in it several times and I want to replace each occurrence of this character with a different string from an array. I.e. just like in prepared statements: String: "SELECT * FROM x WHERE a = ? AND b = ?" Array: ['alpha', 'beta'] Result: "SELECT * FROM x WHERE a = alpha AND b = beta" Is the...

Segmentation fault in equating a char pointer value to some char

Possible Duplicate: Why is this C code causing a segmentation fault? char* string = "abcd"; now when i try to change some character of this string i get segmentation fault *string = 'p'; or string[0] = 'p'; string[0] = 52; Can someone please explain me the reason that why is it happening. Thanks Alok.Kr. ...

Using multiple arguments for string formatting in Python (e.g., '%s ... %s')

I have a string that looks like '%s in %s' and I want to know how to seperate the arguments so that they are two different %s. My mind coming from Java came up with this: '%s in %s' % unicode(self.author), unicode(self.publication) But this doesn't work so how does it look in Python? ...

Difference between JQuery .length() and .NET .Length for Returns

I've written a jQuery function to check the total number of characters in a given textbox and pop up a warning if it exceeds the maximum (user-defined) length. Example: (greatly simplified): function checkLength(txt) { if (txt.length >= maxlength) { alert('Too much text entered'); return false; } else ret...

Separating the components of CSS for database entry

CONTEXT: My project is a CMS website, and each user's CSS is held in a database table. Fields are: int id primary int site_id index string selector string property string value bool important When a user's website is pulled up, it's a simple query: SELECT * FROM css_table WHERE site_id = $this_site_id ...

Optimization of F# string manipulation

Hello, I am just learning F# and have been converting a library of C# extension methods to F#. I am currently working on implementing a function called ConvertFirstLetterToUppercase based on the C# implementation below: public static string ConvertFirstLetterToUppercase(this string value) { if (string.IsNullOrEmpty(value)) return v...

Formatted string parsing and updating

I need to replace specialy marked place holders in string with values. Similar to what string.Format does, but in a bit more advance way. For instance: input string: "Welcome to {Binding Path=@city}!" Value for @city is "Boston" Output string should be "Welcome to Boston!". I can successfully parse input string with regex and get th...

How to best flatten a tab-delimited table?

Here's an example data table (the data are fake, but in the same format as my business data coming from an external system): R1 Pears,Apples,Bananas 10 Oranges 5 R2 Apricots 15 Bananas 222 Apples,Oranges 15 The data are in a string. Columns are tab-delimited, lines are CRLF-delimited....

remove_before()

Is there some better way to do the below? (without having the possibility of a fatal error) function remove_before($needle,$haystack){ return substr(strstr($haystack,$needle),strlen($needle)); } like strstr($haystack,$needle) but without the needle in the returned string, and I might as well ask if this can be improved too... fu...

c - grouping strings in a struct

I have a bunch of strings that look like: 'Hello1-FOO', 'Aello2-FOO', 'Bye1-BAR', 'Bye3-BAR', 'Hello22-FOO', 'Bye4-BAR', 'Welcome-BAR' ... All of them are stored on a struct. struct str { char *strings; } ... struct str **t_str; size_t j; t_str = malloc(sizeof *t_str * 20); for (j = 0; j < 20; j++) t_str[j] = malloc(sizeof *t...

Split html row into string array

I have data in an html file, in a table: <table> <tr><td>001</td><td>MC Hammer</td><td>Can't Touch This</td></tr> <tr><td>002</td><td>Tone Loc</td><td>Funky Cold Medina</td></tr> <tr><td>003</td><td>Funkdoobiest</td><td>Bow Wow Wow</td></tr> </table> How do I split a single row into an array or list? string row = streamRe...

Hex String to Byte Array in C

Is there a standard C function that can convert from hex string to bye array? I do not want to write my own function if there is an already existing standard way. ...

Finding start and end tags in string using regex

I am trying to parse an HTML file ( non strict one) using JavaScript my output should be the same HTML file, but I need to process the internal content of any <script></script> tag. I have a method processScript(script) that does that.. I can assume that there will be no <script/> tags. I have a pretty clear idea how to it using just ...

How to find all occurrences of one string in another in JavaScript?

I'm trying to find the positions of all occurrences of a string in another string, case-insensitive. For example, given the string: I learned to play the Ukulele in Lebanon. and the search string le, I want to obtain the array: [2, 25, 27, 33] Both strings will be variables - i.e., I can't hard-code their values. I figured that th...

Changing Text in PHP

Hey all I haven't found anytihng in Google or the PHP manual, believe it or not. I would've thought there would be a string operation for something like this, maybe there is and I'm just uber blind today... I have a php page, and when the button gets clicked, I would like to change a string of text on that page with something else. So...

Objective C - Number to String and Grab length inconsistencies

I am trying to grab a number from a text box entry, convert it to string and grab the length of it. (IE: Perform a LEN(someInteger) on a number). I have been able to get it working, however there are some inconsistencies when the number is 0 or null. For example; -(IBAction)update { // inputField is the number pad textbox doubl...

Python cut a string after Xth sentence.

I have to cut a unicode string which is actually an article (contains sentences) I want to cut this article string after Xth sentence in python. A good indicator of a sentence ending is that it ends with full stop (".") and the word after start with capital name. Such as myarticle == "Hi, this is my first sentence. And this is my secon...