string

PHP: Implicit conversion to string instead of getting "Object ID #.."

I've moved to a new webhost were we have php 5.1 instead of 5.2 that I've been using until now. I still haven't figured out if it's a php version or configuration issue. Right now most (or all) of the classes that have __toString functions convert to "Object ID #" (like in php4) but before they all returned the correct values. How can ...

How do I trim a file extension from a String in Java?

What's the most efficient way to trim the suffix in Java, like this: title part1.txt title part2.html => title part1 title part2 ...

rijndael encryption

does this encryption library use pipe characters? I'm storing the key in an array with the corresponding UserID value, and delimiting them with a pipe character. If the library generates keys with pipe characters, those keys will get mangled when I split the string later. ...

What's the difference between single and double quotes in Perl?

In Perl, what is the difference between ' and " ? For example, I have 2 variables like below: $var1 = '\('; $var2 = "\("; $res1 = ($matchStr =~ m/$var1/); $res2 = ($matchStr =~ m/$var2/); The $res2 statement complains that "Unmatched ( before HERE mark in regex m". ...

String manipulation in Cython

I have code that does some very CPU-intensive string manipulations and I was looking for ways to improve performance. (EDIT: I'm doing stuff like finding longest common substring, running lots of regular expressions which might be better expressed as state machines in c, stripping comments from HTML, stuff like that.) I am currently lo...

What is the difference between ' and " in JavaScript?

I saw this question and I am wondering about the same thing in JavaScript. If you use the character ' or the character " when making strings in JavaScript, the application seems to behave the same. So what is the difference between these two characters? The only advantage I have seen in using ' to build strings is that I can do stuff l...

String inside of a string Ex: pie = "He said "hi"" - C#

In Visual Studio with C#, how can I declare a string inside of a string like this? I saw a few Stack Overflow pages like "Java string inside string to string", but didn't think any of them were the same as my question. Basically if I have "<?xml version="1.0" encoding="UTF-8"standalone="yes" ?>" How can I declare this, or something l...

What are the most-used string types in C++ and how to convert between them?

OR How to not kill yourself or someone the next time the C++ compiler twists your arm to convert between 2 arbitrary string types just to mess with you? I have a tough time coding in C++ since I am used to VB6, C#, Ruby, for string operations. But now I've spent over 30 mins trying to log a string containing 2 guids and a string to the...

Separating a large string

How do you say something like this? static const string message = "This is a message.\n It continues in the next line" The problem is, the next line isn't being recognized as part of the string.. How to fix that? Or is the only solution to create an array of strings and then initialize the array to hold...

C++/CLI Converting from System::String^ to std::string

Can someone please post a simple code that would convert System::String^ to C++ std::string ? i.e I just want to assign the value of String^ originalString; to std::string newString; ...

Are string constants overrated?

It's easy to lose track of odd numbers like 0, 1, or 5. I used to be very strict about this when I wrote low-level C code. As I work more with all the string literals involved with XML and SQL, I find myself often breaking the rule of embedding constants in code, at least when it comes to string literals. (I'm still good about numeric ...

Is there a better way to count string format placeholders in a string in C#?

I have a template string and an array of parameters that come from different sources but need to be matched up to create a new "filled-in" string: string templateString = GetTemplate(); // e.g. "Mr {0} has a {1}" string[] dataItems = GetDataItems(); // e.g. ["Jones", "ceiling cat"} string resultingString = String.Format(templateS...

how to parse this string in java?

"prefix/dir1/dir2/dir3/dir4/.." how to parse the dir1,dir2 .. value out of the above string in JAVA? The prefix here can be : /usr/local/apache2/resumes ...

Why is the output of these 2 functions different ?

$value = '\\40'; file_put_contents('o.txt',$value); file_put_contents('o2.txt',var_export($value,true)); D:\test>php str.php D:\test>cat o.txt \40 D:\test>cat o2.txt '\\40' ...

Convert String to int

I am trying to write a simple program that asks the user to enter a number and then I will use that number to decide what the cost of the ticket will be for their given age. I am having trouble when trying to convert the string to int. Otherwise the program layout is fine. Any suggestions? thanks using System; class ticketPrice { ...

Replace string in javascript array

Hello. I have an array in javascript. This array has strings that contains commas (","). I want all commas to be removed from this array. Can this be done ? Thanks. ...

In Perl, how can I read an entire file into a string?

So I'm working on a server where I can't install any modules whatsoever. Yes this makes my job difficult. To complete the rest of my script I need to do something that I had thought would be fairly straightforward but it seems to be anything but. I'm trying to open an .html file as one big long string. This is what I've got: ope...

What would be the best way to use string functions and alteration on one string?

What should be the best way to write code: 1) Dim current = Request.Path current = current.Remove(0, 1) current = current.Replace(".aspx", "") 2) Dim current = Request.Path.Remove(0, 1).Replace(".aspx", "") 3) Dim current = Request.Path Dim current2 = current.Remove(0, 1) Dim current3 = current.Replace(".aspx", "") Or 1-2 mak...

Search for strings matching the pattern "abc:*:xyz" in less than O(n)

Given a bunch of strings I need to find those which match 3 kinds of patterns: Prefix search - abc* Glob-like pattern - abc:*:xyz Suffix search - *xyz where * is a wildcard (and can match any number of chars). Now the straight-forward solution is just to scan every string and see if it matches the target pattern. But this is O(n). I...

Search a sentence in a string (C#)

Hi, My question has two parts: 1) How can I search for a sentence (e.g., Dell Canada) in a string (e.g., I am working in Dell Canada, and I found it...) . 2)The second part is my string is text in a RichTextBox, so I would like to find the TextRange of that selected sentence and apply certain decoration. thanks. ...