string

Compare values from data source to string

Hey folks, I'm just stumped on what to do with this code, I'm just trying to implement a 'no duplicates' catch on my insert customer form, but it just slips through my if statement to the else everytime. This is the source. Also I tried a .Equals with the same results :( Protected Sub srcAllClients_Inserting(ByVal sender As Object, By...

Python. Path in variable.

How can I add letter to path? For example if i have a path like 'c:\example2\media\uploads\test5.txt' (stored in a variable), but I need something like r'c:\example2\media\uploads\test5.txt', how can I add letter `r? Because the function open() does not want to open the first path. When I try add path to function open() it gives me an ...

Converting an uint64 to string in C++

What's the easiest way to convert an uint64 value into a standart C++ string? I checked out the assign methods from the string and could find no one that accepts an uint64 (8 bytes) as argument. How can I do this? Thanks Nelson R. Pérez ...

How to implement C++0x raw string literal?

How to define a working set of lexer and parser (exempli gratia: flex and bison) to support the C++0x styled raw string literals? As you may already know, new string literals in C++0x can be expressed in a very flexible way. R"<delim>...<delim>"; - in this code the <delim> can be pretty much everything and also no escape characters...

Is there a way to build a Java String using an SLF4J-style formatting function?

I've heard that using StringBuilder is faster than using string concatenation, but I'm tired of wrestling with StringBuilder objects all of the time. I was recently exposed to the SLF4J logging library and I love the "just do the right thing" simplicity of its formatting when compared with String.format. Is there a library out there th...

In a batch file, Combining two strings to create a combined path string

I need to take two strings and combine them into a single path string inside a batch file similar to the Path.Combine method in .Net. For example, whether the strings are "C:\trunk" and "ProjectName\Project.txt" or "C:\trunk\" and "ProjectName\Project.txt", the combined path will be "C:\trunk\ProjectName\Project.txt". I have tried using...

Double forward slash in a string using stripos() will not match a string even if it is present?

I ran into a little problem today when I was creating a really quick script to scan lines files in a user specified directory for //todo:... So I had a line like this: if (stripos($data, '//todo:')) { //case-insensitive search ^^ //deal with the data appropriately } This did not find //todo: anywhere in any of the files! This was ...

How to concatenate using lstrcat in Visual C++?

Hi, I would like to append two strings together so that I can rename a file using the MoveFile function. But my strings refuse to concatenate, so instead of adding "E:\" to "FILE-%s-%02d%02d%02d-%02d%02d.txt" to give me "E:\FILE-%s-%02d%02d%02d-%02d%02d.txt", it gives me just "E:\" as if nothing happened. Here is a snippet of my full c...

Lua function return string with C++

Is it possible to add a function to Lua via C++ that returns a string? -edit- Ok, this code wont work. Any help? int flua_getinput(lua_State *L){ if(lua_isstring(L,1)){ cout << lua_tostring(L,1); cin >> input; cout << "\n"; lua_pushstring(L,input); }else{ cin >> input; cout << "\n"...

PHP constant string square bracket indexing

I'm trying to get a constant string and index it as if it was an array of characters (square bracket syntax). When I try this code it fails on the last line. define( 'CONSTANT_STRING','0123456789abcdef'); echo CONSTANT_STRING; // Works by itself :) $string = CONSTANT_STRING; echo $string[9]; // Also works by itself. echo strlen(CONSTAN...

Is there any other reason beside performance and readiblity of why System.String is a reference type instead of value type?

Why was String designed as a reference type instead of value type? From the modeling perspective I would have modeled it as a value type since it represents something without identity. It doesn't have distinguishing attributes. (E.g I can't make any difference between one string "a" and another string "a") I know that I would have ha...

How to split strings based on capitalization?

Possible Duplicate: Python: Split a string at uppercase letters I'm trying to figure out how to change TwoWords into Two Words and I can't think of a way to do it. I need to split based on where it's capitalized, that will always be a new word. Does anyone have any suggestions? In python. ...

Extract specific part of a string in PHP

Hey guys, I was simply wondering what would be the simplest and most efficient way of extracting a certain part of a dynamic string in PHP? Per example, in this string: http://www.dailymotion.com/video/xclep1_school-gyrls-something-like-a-party_music#hp-v-v13 I'd only like to extract (and insert in a variable) the: " xclep1_school-gy...

PHP __toString does not work with trigger_error as advertised

It is known that __toString cannot throw an exception but I have read ( Link 1, Link 2 ) that it supports trigger_error so I tried the following code: public function __toString() { try { return $this->render(); } catch (Exception $e){ trigger_error($e->getMessage()); return ''; ...

C# Comparing strings with different case

I'm reading a username and then checking to see if exists in another database table, the problem is whilst the username is the same the case maybe different and is preventing it from finding a match example jsmith and JSmith or JSMITH. How can I fix this? Should I lower the case when writing to the first database or can I alter my code ...

Whats wrong with this c++ reverse string function

void reverse (char s[]){ int len = strlen(s); int j = len - 1; for (int i = 0; i < j; i++,j--){ cout << s[i]; char ch = s[i]; s[i] = s[j]; //error line - giving exception, cannot write to the memory s[j] = ch; } } I am using Visual Studion 2008 and i can't understand whats the problem here .. :s .. I am out of C++ p...

Copying a string to a fixed length byte buffer in a structure

given this structure in c#: [StructLayout(LayoutKind.Sequential)] unsafe public struct AppVPEntry { public int Num; public fixed byte CompName[256]; public int VPBeginAddress; } Whats the easiest way to copy a string ("c:\path\file.txt") to the fixed length buffer 'CompName'. This is in a structure thats being sent over ...

Ruby String::gsub! pausing unexpectedly

Hello Everyone! I am working on a VERY simple script to clean up a few hundred thousand small XML files. My current method is to iterate through the directory and (for each file) read the file, use String::gsub! to make all my changes (not sure if this is best) and then I write the new contents to the file. My code looks something like ...

Contains is faster than StartsWith?

A consultant came by yesterday and somehow the topic of strings came up. He mentioned that he had noticed that for strings less than a certain length, Contains is actually faster than StartsWith. I had to see it with my own two eyes, so I wrote a little app and sure enough, Contains is faster! How is this possible? DateTime start = D...

Ruby on Rails: Interpreting a form input as an integer

I've got a form that allows the user to put together a hash. The hashes desired end format would be something like this: {1 => "a", 2 => "x", 3 => "m"} I can build up something similar by having lots of inputs that have internal brackets in their names: <%= hidden_field_tag "article[1]", :value => a %> However, the end result is t...