string

boost::ifind_first problem

I am trying to use boost string algorithms for case insensitive search. total newbie here. if I am using it this way, I get an error. std::string str1("Hello world"); std::string str2("hello"); if ( boost::ifind_first(str1, str2) ) some code; Converting to char pointers resolves the problem. boost::ifind_first( (char*)str1.c_str(), ...

Raw Strings in Java?

Is there any way to use raw strings in Java (without escape sequences)? (I'm writing a fair amount of regex code and raw strings would make my code immensely more readable) I understand that the language does not provide this directly, but is there any way to "simulate" them in any way whatsoever? ...

Porting file preprocessing code from C to C#

Hi, I've made a basic interpreter before in C with a preprocessor that took a lot of load off of parsing and such. I would like to port this preprocessor for use in C# now and I'm having trouble, as I am still quite new to C#. My old preprocessor made it so things like var $mine= this; //weird intendtation var $some...

Typecast:LPCTSTR to Char * for string concatenate operation

Can u Give solution for this code of typecasting, LPCTSTR(here lpsubkey) to Char* for below code snippet , char* s="HKEY_CURRENT_USER\\"; strcat(s,(char*)lpSubKey); printf("%S",s); here it makes error of access violation ,so what will be the solution for that?. ...thanks in advance ...

Pythonic way of searching for a substring in a list

I have a list of strings - something like mytext = ['This is some text','this is yet more text','This is text that contains the substring foobar123','yet more text'] I want to find the first occurrence of anything that starts with foobar. If I was grepping then I would do search for foobar*. My current solution looks like this for...

substring algorithm

Can anyone point to best algorithm for substring search in another string? or search for a char array in another char array? ...

Escape a string (add slashes) in VB.net?

Very simple question (surprisingly I can't find a similar question anywhere): how do I escape form data in VB.net? I have various lines like this: Dim query As String = "exec sp_Message_insert @clientid='" + pClientId + "', @message='" + pMessage + "', @takenby='" + pUserId + "', @recipients='" + pRecipients + "'" If I use an apostrop...

How to replace Microsoft-encoded quotes in PHP

I need to replace Microsoft Word version of single and double quotations marks (“ ” ‘ ’) with regular quotes (' and ") due to an encoding issue in my application. I do not need them to be HTML entities and I cannot change my database schema. I have two options: to use either a regular expression or an associated array. Is there a bett...

Cut strings short PHP

How would you go about Cutting strings short so it doesnt go to the next line in a div tag For example my message string contained the following: We prefer questions that can be answered, not just discussed. Provide details. Write clearly and simply. If your question is about this website, ask it on meta instead. And i want to pref...

C#: How do I read a specified line in a text file?

Given a text file, how would I go about reading an arbitrary line and nothing else in the file? Say, I have a file test.txt. How would I go about reading line number 15 in the file? All I've seen is stuff involving storing the entire text file as a String array and then using the value of the line number as the number of the String to...

Does List<String>.Contains(mystring) do a reference comparison or a value comparison?

Does List.Contains(mystring) do a reference comparison or a value comparison? Eg I have this code: /// <summary> /// If the value isn't null or an empty string, /// and doesn't exist in the list, it adds it to the list /// </summary> static void AddToListIfNotEmpty(List<string> thelist, SqlString val) { string value = val.ToString()....

Given Server Relative URL, quickest way to find the last thing (i.e. after final slash)

I'm assuming: String abc = "My Documents/FileName.txt".Split('/')[1]; // is not the quickest way Is it? ...

string interpolation in haskell

Hi, I want to write the code that will output : length [1,2,3] => 3 In Ruby, I could do it like : puts "length [1,2,3] => #{[1,2,3].length}" Following try is Haskell failed... Prelude Data.List> print "length [1,2,3]" "length [1,2,3]" Prelude Data.List> print (length [1,2,3]) 3 Prelude Data.List> print "length [...

How to extract a substring from a string in java

Hello. What I am doing is validating URLs from my code. So I have a file with url's in it and I want to see if they exist or not. If they exist, the web page contains xml code in which there will be an email address I want to extract. I go round a while loop and in each instance, if the url exists, The xml is added to a string. This one...

String compare with 'strange chars' in SqlServer

I have some content in our database with (for our language) 'strange' characters. For example: Å When using the like statement in Sql Server with the letter A, this does not return a result because the Å is not an A. Is there a way in SqlServer to treat the Å as an E (and the é as an 'e' etc)? ...

Python: Check if a string represents an int, Without using Try/Except?

Hi, Is there any way to tell whether a string represents an integer (e.g., '3', '-17' but not '3.14' or 'asfasfas') Without using a try/except mechanism? is_int('3.14') = False is_int('-7') = True Thanks, Adam ...

string to integer in xslt

Hi i want to conver a string value in xslt to a integer value.I am using xslt 1.0 so i can't use those functions supported in xslt 2.0 . Please help . ...

PHP heredoc parse error

This produces output page OK $mystring = "<<<EOT"; Replacing it with the following produces Parse error: syntax error, unexpected $end in file.php on line 737 $mystring = <<<EOT This is some PHP text. It is completely free I can use "double quotes" and 'single quotes', plus $variables too, which will be properl...

How do I calculate the numeric value of a string with unicode components in python?

Along the lines of my previous question, http://stackoverflow.com/questions/1263796/how-do-i-convert-unicode-characters-to-floats-in-python , I would like to find a more elegant solution to calculating the value of a string that contains unicode numeric values. For example, take the strings "1⅕" and "1 ⅕". I would like these to resolve...

Does __str__() call decode() method behind scenes?

It seems to me that built-in functions __repr__ and __str__ have an important difference in their base definition. >>> t2 = u'\u0131\u015f\u0131k' >>> print t2 ışık >>> t2 Out[0]: u'\u0131\u015f\u0131k' t2.decode raises an error since t2 is a unicode string. >>> enc = 'utf-8' >>> t2.decode(enc) ---------------------------------------...