string

In Ruby, can you perform string interpolation on data read from a file?

In Ruby you can reference variables inside strings and they are interpolated at runtime. For example if you declare a variable `foo' equals "Ted" and you declare a string "Hello, #{foo}" it interpolates to "Hello, Ted". I've not been able to figure out how to perform the magic "#{}" interpolation on data read from a file. In pse...

JSON to string in Prototype

The people on this website seem to know everything so I figured I would ask this just in case: Is there a method/function in prototype that converts a JSON object to a string that you can store in a cookie? If not,..i'll just use another external library. Thanks, Andrww ...

How do you search a std::string for a substring in C++?

I'm trying to parse a simple string in C++. I know the string contains some text with a colon, followed immediately by a space, then a number. I'd like to extract just the number part of the string. I can't just tokenize on the space (using sstream and <<) because the text in front of the colon may or may not have spaces in it. Some ...

Convert std::string to const char* or char*

How can I convert an std::string to a char* or a const char*? ...

deadlock on synchronized ( String intern())

I user sun jdk 1.5 ThreadPoolExecutor( 24, 24,60,TimeUnit.SECONDS, new LinkedBlockingQueue()). soemtime I use jdb tool to find the status of all threads in thread pool are " waiting in a monitor", the code is : String key = getKey(dt.getPrefix(), id); synchronized (key.intern()) { -----> Is there a problem in "synchronized (...

Is a string literal in c++ created in static memory?

Is a string literal in c++ created in static memory and destroyed only when the program exits? ...

How do I match a square bracket literal using RegEx?

What's the regex to match a square bracket? I'm using \] in a pattern in eregi_replace, but it doesn't seem to be able to find a ]... ...

How can I convert a REG_BINARY value from the registry into a string ? (vb.net)

I have a registry value which is stored as a binary value (REG_BINARY) holding information about a filepath. The value is read out into an byte array. But how can I transform it into a readable string? I have read about system.text.encoding.ASCII.GetString(value) but this does not work. As far as I got to know the registry value is arbi...

How do you detect repetitions in a list of strings?

I have a sequence of SQL calls, which I want to use to detect loops (and hence unnecessary duplicate sql calls), but it got me thinking of this more general problem. Given a list, say [a,b,c,b,c,a,b,c,b,c,a,b,b] Is there some way I can turn that into a,[[b,c]*2,a]*2,b*2 or, [a,[b,c]*2]*2,a,b*2 That is, detect repetitions (possibly ne...

How can I perform a reverse string search in Excel without using VBA?

I have an Excel spreadsheet containing a list of strings. Each string is made up of several words, but the number of words in each string is different. Using built in Excel functions (no VBA), is there a way to isolate the last word in each string? Examples: Are you classified as human? -> human? Negative, I am a meat popsicle -> p...

How to escape slash (/) in VBScript?

How do you escape the forward slash character (/) in VBScript? For example, in the following string: bob = "VU administration/front desk" ...

How to best match two strings?

Hi, do you know any good algorithms that match two strings and then return a percentage in how many percent those two strings match? And are there some, that work with databases too? ...

Capitalize a string

Hi, Does anyone know of a really simple way of capitalizing just the first letter of a string, regardless of the capitalization of the rest of the string? For example: asimpletest -> Asimpletest aSimpleTest -> ASimpleTest I would like to be able to do all string lengths as well. Thanks, Dan ...

Store Variable Name in String in VB.NET

I'm trying to store the names of some variables inside strings. For example: Dim Foo1 as Integer Dim Foo1Name as String ' -- Do something to set Foo1Name to the name of the other variable -- MessageBox.Show(Foo1Name & " is the variable you are looking for.") ' Outputs: ' Foo1 is the variable you are looking for. This would help with...

Verbatim Literals in Managed C++? (like C#'s @"blah")

Is there a way to use verbatim String literals in managed C++? Similar to C#'s String Docs = @"c:\documents and settings\" ...

SQL character field concatenation (without using CONCAT() or +)

Hey.. I'm trying to concatenate 3 [char(32)] fields:title1title2title3 into one field, but the catch is that I'm using an older version of SQL and it DOES NOT support the CONCAT() subroutine or the + operatorfor example:CONCAT(title1, title2, title3)(title1 + title2 + title3) DON'T WORK!!!!Is there another way? ...

In Javascript, what is the difference between indexOf() and search()?

Being fairly new to Javascript, I'm unable to discern when to use each of these. Can anyone help clarify this for me? ...

sprintf() without trailing null space in C

Is there a way to use the C sprintf() function without it adding a '\0' character at the end of its output? I need to write formatted text in the middle of a fixed width string. ...

What are strings really in .NET?

Is a string actually a character array (is-a), or does it have a character array as an internal store (has-a), or is it's own object which can expose itself as a with an array of characters? I am more inclined to say it is it's own object, but then why are we so inclined to always say "A string is an array of characters..."? ...

string replace on escape characters

Today I found out that putting strings in a resource file will cause them to be treated as literals, i.e putting "Text for first line \n Text for second line" will cause the escape character itself to become escaped, and so what's stored is "Text for first line \n Text for second line" - and then these come out in the display, instead of...