string

Avoid creating 'new' String objects when converting a byte[] to String using a specific charset

I'm reading from a binary file and want to convert the bytes to US ASCII strings. Is there any way to do this without calling new on String to avoid multiple semantically equal String objects being created in the normal object pool? I'm thinking that it is probably not possible since introducing String objects using double quotes is not ...

Parse from a list with a quote in text.

I want to put these strings in a list, how do I do that? The hold up is the double "", found in the first two lines, how can I work around this? scriptTxt = new string[] { "#$language = "VBScript"", "#$interface = "1.0"", "crt.Screen.Synchronous = True", "Sub Main" }; ...

Java Properties Object to String

I have a Java Properties object that I load from an in-memory String, that was previously loaded into memory from the actual .properties file like this: this.propertyFilesCache.put(file, FileUtils.fileToString(propFile)); The util (fileToString) actually reads in the text from the file and the rest of the code stores it in a HashMap (...

Easy way to concatenate list of strings into a comma-separated strings, where strings are members of an object?

Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members. Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function? Thanks! ...

Split a string in ASP Javascript

I am trying to split a string from a recordset that is in the format DD/MM/YYYY. So basically something like: Homework.Fields.Item("DateDue").Value.split("/") But that doesn't work, Normally I can do: String(Homework.Fields.Item("DateDue").Value).split("/") But using String() turns the value into a long thing like: Wed Oct 26 00:...

PHP Japanese Strings getting set to ????????????

I have a PHP file with one simple echo function: echo 'アクセスは撥ねりません。'; but when I access that page i get this: ???????????? Can someone help me? I also have my page encoding set to UTF-8, and I know it, because all of the browsers i used said so. I also do this before the echo function: mb_internal_encoding('UTF-8'); What does th...

Is jquery ":contains" selector accepts this kind of value "Banking and Finance"?

Hello guys, I'm having problem with the contains in jquery. It seems that it only accepts one word. Not a phrase or two words. Example: $('#div:contains('Word')'); --> This is okay $('#div:contains('Just another word')'); --> This will return empty/this will not match. Have you experience this kind of problem? Your reply is greatl...

Using strtok() on an allocated string?

Is there anything I should know about using strtok on a malloced string? In my code I have (in general terms) char* line=getline(); Parse(dest,line); free(line); where getline() is a function that returns a char * to some malloced memory. and Parse(dest, line) is a function that does parsing online, storing the results in dest, (whic...

PHP - Replace strings in first array with values from second array

For some reason I'm struggling with this. I have the following 2 arrays and I need to take the array values from the $img array and insert them in order into the $text array, appending/replacing the %img_ tags, like so: $text = array( 0 => "Bunch of text %img_ %img_: Some more text blabla %img_", 1 => "More text %img_ blabla %i...

How to read cin with whitespace up until a newline character?

I wish to read from cin in C++ from the current position up until a newline character into a string. The characters to be read may include spaces. My first pass fails because it stops on the first space: string result; cin >> result; If cin is given: (cd /my/dir; doSometing)\n The variable result only gets: (cd I would think ...

Better way to do string filtering/manipulation

Hello I have this string: mystring = '14| "Preprocessor Frame Count Not Incrementing; Card: Motherboard, Port: 2"|minor' So I have 3 elements (id, message and level) divided by pipe ("|"). I want to get each element so I have written these little functions: def get_msg(i): x = i.split("|") return x[1].strip().repl...

How do I strip whitespace from a string in OCaml?

To learn the basics of OCaml, I'm solving one of the easy facebook engineering puzzles using it. Essentially, I'd like to do something like the following Python code: some_str = some_str.strip() That is, I'd like to strip all of the whitespace from the beginning and the end. I don't see anything obvious to do this in the OCaml Str l...

Grep multi-layered iterable for strings that match (Python)

Say that we have a multilayered iterable with some strings at the "final" level, yes strings are iterable, but I think that you get my meaning: ['something', ('Diff', ('diff', 'udiff'), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch')), ('Delphi', ('delphi', 'pas', 'pascal', 'objectpascal'), ('*.pas',), ('text/x-pascal',['lets',...

A C style string file format conundrum

I'm very confused with this wee little problem I have. I have a non-indexed file format header. (more specifically the ID3 header) Now, this header stores a string or rather three bytes for conformation that the data is actually an ID3 tag (TAG is the string btw.) Point is, now that this TAG in the file format is not null-terminated. So ...

parsing string to a dict

I have a string output which is in form of a dict ex. {'key1':'value1','key2':'value2'} how can make easily save it as a dict and not as a string? ...

Add strings to array PHP

Hello I have $string1, Array[] and $string2. I want to create a Arraynew[] such that Arraynew[0]=$string1 Arraynew[1]=Array[0] . . . Arraynew[n-1]=Array[n] Arraynew[n]=$string2 The problem being that I don't know how many elements are in Array[] since it's from parsed data that changes and also I don't know how to formulate the above ...

loop through an array and find partial string

if i have array array[0] = "jack"; array[1] = "jill"; array[2] = "lisa"; array[2] = "jackie"; and i want to find all elements with "ack" in it. in this case it would return "jack", "jackie". what is the fastest way of doing this? ...

Escape sequence for ? in c++

Hi, I was looking at the escape sequences for characters in strings in c++ and I noticed there is an escape sequence for a question mark. Can someone tell me why this is? It just seems a little odd and I can't figure out what ? does in a string. Thanks. ...

Java string to bytearray back to string

I have a client and server java application that needs have encrypted text passing through each other. I am using an XOR encryption the encrypt the text that I want. The problem is that readline() doesn't accept string that has been XORed and will only if accepted if it is in bytes. So I've converted my plaintext (string) into a byte a...

Need some help with String.format

Hi. I'm trying to find a complete tutorial about formatting strings in java. I need to create a receipt, like this: HEADER IN MIDDLE '''''''''''''''''''''''''''''' Item1 Price Item2 x 5 Price Item3 that has a very long name.... Price '''''''''''''''''''''''''''''' Netprice: ...