string

How to convert the DataInputStream to the String in Java?

Hi, everyone, I want to ask a question about Java. I have use the URLConnection in Java to retrieve the DataInputStream. and I want to convert the DataInputStream into a String variable in Java. What should I do? Can anyone help me. thank you. The following is my code: URL data = new URL("http://google.com"); URLConnection dataConnect...

Converting string to time

Hi, I have string like this:"0:385" (first number is seconds, next numbers are milliseconds), I want to use in datagridview with sorting like numbers (not like strings) so I am trying to make DateTime from string but I am not sure how exactly do this. I know I should use method Parse (or ParseExact) but when I tried it it says "String wa...

what is a wrong in this code?

i have following code #include <iostream> #include <string> using namespace std; string replace(string s){ for (int i=0;i<s.length();i++){ if (s[i]> 'b' && s[i]<'f'){ s.erase(s[i]); } } return s; } int main(){ string s; cin>>s; cout<<replace(s)<<endl; return 0; } if i en...

In Perl, how can I replace only the first character of a string?

I don't know the slightest bit of Perl and have to fix a bug in a Perl script. Given a variable $myvar which contains a string, if the first character is a dot, replace it with "foo/bar". How can I do this? (Bonus points if you can guess the bug) ...

In Perl, how can I use a string as a variable name?

Possible Duplicate: How can I use a variable as a variable name in Perl? Is this doable? I need to change a string into variable. Example: If I have a variable like this: $this_is_test = "what ever"; $default = "this"; $default = $default . "_is_test"; I want $default to take the value of $this_is_test. ...

Internet explorer 8 JScript regular expression bug

I'm testing in internet explorer 8 on windows XP and hitting into a tedious bug. I am trying to test strings with a regular expression that works fine in firefox and fine tested indepedantly in the ie8 console. But when it through my closure function the string acts strangly [Edit] more detailed code:- Not as nice or clean as the earli...

Why do Strings start with a "" in Java?

Possible Duplicate: Why does abcd.StartsWith() return true? Whilst debugging through some code I found a particular piece of my validation was using the .startsWith() method on the String class to check if a String started with a blank character Considering the following : public static void main(String args[]) { Strin...

c++ string allocation

do I need to take care of memory allocation, scope and deletion about c++ "string" object? for example: #include <string> const char* func3() { string s = "this is a literal string"; return s.c_str(); } string func2() { string s = "this is a literal string"; return s; } const char* func1() { const char* s = "this is a...

Finding multiple occurrences of a string within a string in Python

Hi there. How do I find multiple occurrences of a string within a string in Python? Consider this: >>> text = "Allowed Hello Hollow" >>> text.find("ll") 1 >>> So the first occurrence of ll is at 1 as expected. How do I find the next occurrence of it? Same question is valid for a list. Consider: >>> x = ['ll', 'ok', 'll'] How do ...

php - Is strpos the fastest way to search for a string in a large body of text?

if (strpos(htmlentities($storage->getMessage($i)),'chocolate')) Hi, I'm using gmail oauth access to find specific text strings in email addresses. Is there a way to find text instances quicker and more efficiently than using strpos in the above code? Should I be using a hash technique? ...

Identical strings comparison gives me false

I have two identical strings, one in an array and one in a String variable. When I compare these IDENTICAL strings I get false every time. I have debugged and debugged, but I get the same result every time. Here is the code in question String temp = ""+(num1*num2); Boolean equal = temp == answers[i]; if(equal) { correct[i] = true; ...

python: how to remove certain characters

how do i write a function removeThese(stringToModify,charsToRemove) that will return a string which is the original stringToModify string with the characters in charsToRemove removed from it. ...

JRuby: Create Java InputStream or byte[] from RubyString

I have a Java method I want to call from JRuby. The argument I want to pass is just a normal string (org.jruby.RubyString), but the Java method is overloaded to take either: java.io.InputStream byte[] com.google.protobuf.ByteString What's an easy way I can convert my string to an instance of one of those classes? ...

how to find out is a long string contatins a word obj c, iphone

I have a long string that has a running list of all the "words entered" in the text box. I want to be able to check the long string against a one word string to see if the long string contains the word in the short string. Any ideas? I've tried this and a few other things, where newString is the long string and currentTextrightnow is ...

Given a string in Java, just take the first X letters.

Is there something like a C# Substring for Java? I'm creating a mobile application for Blackberry device and due to screen constraints I can only afford to show 13 letters plus three dots for an ellipsis. Any suggestion on how to accomplish this? I need bare bones Java and not some fancy trick because I doubt a mobile device has acces...

Trimming a string of Int

In my program i want to input a string of integer e.g 2107900000. I want to get its length and then want to remove all the 0's and 1's. ...

" escape sequence in C?

What is the escape sequence for ' " ' in C? In other words, how can i ask a while-statement to search for an occurance of ' " '? ...

How to replace repeated instances of a character with a single instance of that character in python

I want to replace repeated instances of the "*" character within a string with a single instance of "*". For example if the string is "***abc**de*fg******h", I want it to get converted to "*abc*de*fg*h". I'm pretty new to python (and programming in general) and tried to use regular expressions and string.replace() like: import re p...

Java Reflection API - Getting the value of a String[] field.

I was wondering if it is possible to grab a String[] of an unknown size from a class using the java reflection API and store it elsewhere? Thanks. ...

C#: how to get first char of a string?

Can the first char of a string be retrieved by doing the following? MyString.ToCharArray[0] ...