string

Colon in JSON string

Can I escape a colon : that is inside a JSON string? Currently this object/value set { pn: "MT46H128M16LFCK-5 IT:A", visible: false, url: "/$ws$/29/1/products/ProductDetails.html?product=products/dram/MT46H128M16LFCK-5 IT" } doesn't get read. I suspect it's due to the :A in the pn value. How do I escape it or otherwise grab it...

Get specific value from Object in PHP

<?php $a['registrationID']="*******"; $a['password']="******"; $a['smsPort']=7424; $a['msgID']=0; $soap_url='http://localhost/WebService_GP_ADP_BizTalk_SMS_Orchestrations.wsdl'; $soap = new SoapClient($soap_url); $response=$soap->getReceivedSMS( array ("ReceiveSMSRequest" => $a) ); print_r($response); ?> This returns: stdClass Ob...

How do I do a levenstein similarity algorithm in MYSQL?

Sure, I can write a function for it in Python or something...but how can I do it in MYSQL? WHERE title = "heart of darkness" more or less 3 characters... ...

Substring in SQL

I have a table doctors ( id int, name varchar(255) ) where name like "Sername Name". In query i need only Sername of doctor. How can i do it with standard or with solution on most RDBMS? I know only two solution. First is SUBSTRING(input SIMILAR pattern ESCAPE escape-char) in postgres is SUBSTRING(input FROM pattern-string). Sec...

<string.h> conflicting with my own String.h

Hi! I have a project that was compiling ok within g++(I can't see the version right now) and now on xCode it is not. I think that I got the problem now... I have a String.h file in my project and it seems tha the xCode compiler(that is gcc) is trying to add my own string file from the < cstring >... I am not sure of it, but take a look ...

How does Haskell order Strings?

I've recently been learning Haskell, and I noticed that the String type (or [Char]) can be ordered. For example, this is valid: ghci> "foo" > "bar" True ghci> "?<>!" `compare` "[&*}" LT How does Haskell order Strings, and when would this functionality be useful? ...

Question about strpos. How to get 2nd occurrence of the string?

I understand that this function will get the first occurrence of the string. But what I want is the 2nd occurrence. How to go about doing that? ...

Most performant way to store large amounts of static strings

in my C# application i need to store huge amounts of constant strings in arrays, like one array for first names and one for last name and so on... These strings never change so my question is how to store them ? Make a static constant class with these arrays ? Load them at runtime from somewhere? Or any other solution... PS: I don't...

C++: wide characters outputting incorrectly?

My code is basically this: wstring japan = L"日本"; wstring message = L"Welcome! Japan is "; message += japan; wprintf(message.c_str()); I'm wishing to use wide strings but I do not know how they're outputted, so I used wprintf. When I run something such as: ./widestr | hexdump The hexidecimal codepoints create this: 65 57 63 6c 6...

Is it possible to generate an example string based on a regex pattern?

Dear reader, In my application the user can enter his own regex pattern into a text box so he can force a certain input for another user/text box. Is it possible for the user to see an example of a string that would match the regex he has entered? For example if he was to enter: ^[A-Z]{2}$, it would generate a string like "XX" to show t...

How to correctly assign a new String value in C

Hi, i'm trying to understand how to solve this trivial problem in C in the cleanest/safest way: A simple String replacement. Here's my example: #include <stdio.h> int main(int argc, char *argv[]) { typedef struct { char name[20]; char surname[20]; int unsigned age; } person; //Here i can pass s...

PHP string manipulation: Append html class to a string

Hi I have this string: $str = '<div class="defaultClass">...</div>'; how do I append 'myClass' next to 'defaultClass' ? ...

Convert Unix Timestamp to human format in Django with Python

Hi, I'd like to a convert unix timestamp I have in a string (ex. 1277722499.82) into a more humanized format (hh:mm:ss or similar). Is there an easy way to do this in python for a django app? This is outside of a template, in the model that I would like to do this. Thanks. edit I'm using the python function time.time() to generate the...

RegExp - Grabbing only the important information from a string

I tried the following at http://gskinner.com/RegExr, there it worked perfectly. Now I want to get the /(?&lt;=>\r\s{23})(.*)/gi pattern realized in PHP. The > character don't perform well, also not with backslashes... I want to get the &nbsp;&nbsp;2011&nbsp;Oct&nbsp;3, Mon, Unity Day and &nbsp; in the mid of every <FONT></FONT>. Searc...

c# parse a string that contains conditions , key=value.

I m giving a string that contains several different combination of data. For example : string data = "(age=20&gender=male) or (city=newyork)" string data1 = "(job=engineer&gender=female)" string data2 = "(foo =1 or foo = 2) & (bar =1)" I need to parse this string and create structure out of it and i have to evaluate this to a condi...

Why doesn't this NSPredicate work?

I have a very simple NSPredicate as such: NSPredicate *sPredicate = [NSPredicate predicateWithFormat:@"name beginswith '%@'", theString]; [matchingTags filterUsingPredicate:sPredicate]; This causes the array to have 0 results when theString == "p" However, when I do this: NSPredicate *sPredicate = [NSPredicate predicateWithFormat:@"...

What are good test cases for benchmarking & stress testing substring search algorithms?

I'm trying to evaluate different substring search (ala strstr) algorithms and implementations and looking for some well-crafted needle and haystack strings that will catch worst-case performance and possible corner-case bugs. I suppose I could work them out myself but I figure someone has to have a good collection of test cases sitting a...

Visual Studio 2008 likes to insert random strings into my code

Here's the setup: I have some controls with text fields that I wish to be blank. So I might have, in my designer file: someControl.HeaderText = "" or someControl.HeaderText = Properties.Resources.blank_string THis only seems to happen when i'm trying to specify a blank string for a text or headertext property to a control. If I op...

extracting the first word of a string using php

I want to split a string into two variables, the first word and the rest of the string. The first word is only ever going to be one of 4 different words. $string = explode (' ', $string, 2); $word = $string[0]; $string = $string[1]; The above seems like it works, but I'm wondering if there is a better way. ...

String recurring subsequences and compression

Hi, I'd like to do some kind of "search and replace" algorithm which will, in an efficient manner if possible, identify a substring of a string which occurs more than once and replace all occurrences of that substring with a token. For example, given a string "AbcAdAefgAbijkAblmnAbAb", notice that "A" recurs, so reduce in pass one to "#...