string

frequency analysis algorithm

Hello everyone. I want to write a java program that searches through a cipher text and returns a frequency count of the characters in the cipher, for example the cipher: "jshddllpkeldldwgbdpked" will have a result like this: 2 letter occurrences: pk = 2, ke = 2, ld = 2 3 letter occurrences: pke = 2. Any algorithm that allows me to ...

[VHDL] How to generate serial signal from string?

How do I send data represented by a binary string (e.g. "01011101000100111", length is variable) to an std_logic signal given either fixed delay or clock signal? I want this for a testbench so I'd want to be able to arbitrarily change the binary string with as little hassle as possible, so I'm thinking of using generate. ...

C - How to justify output lines using printf() to get equal length?

I have two functions, one which produces messages like "Starting initialization..." and the other which cheks return codes and outputs "Ok\n", "Warning\n", or "Error\n". However, produced output is of the different length: Starting initialization...Ok. Checking init scripts...Ok. How can I get smth. like that: Starting initialization...

Parsing a string which represents a list of tuples

I have strings which look like this one: "(8, 12.25), (13, 15), (16.75, 18.5)" and I would like to convert each of them into a python data structure. Preferably a list (or tuple) of tuples containing a pair of float values. I could do that with eval("(8, 12.25), (13, 15), (16.75, 18.5)") which gives me a tuple of tuples, but I don't ...

How can I remove a word from string?

I have a string which contains words with parentheses. I need to remove the whole word from the string. For example: for the input, "car wheels_(four) klaxon" the result should be, "car klaxon". Can someone give me an example that would accomplish this? ...

Java - is there an Inbuilt function for concatenating the Strings in a String[]?

Or a better way than this? String concat(String[] strings) { StringBuilder out = new StringBuilder(); for(String next: strings) { out.append(next); } return out.toString(); } No worries if no, I just feel like there should be a built in? ...

name="option11",name="option21",name="option31",name="option41",1,2,3,4.., is a variable. How to write the code?

$html=<<<html <div>A:<input type="text" maxlength="40" size="8" name=option$i."1" value='$option1'/>(answer)</div><br/><br/> html; echo $html; $i is a variable. For example, when $i=5, the value of name should be "option51". So the HTML code should be <div>A:<input type="text" maxlength="40" size="8" name="option51" value='$option...

Capture bitstream into string

I'll need to capture my bitstream into a string and keep concatenating the string. However, I'm not really sure how it's to be done. Any ideas? #include <bitset> #include <iostream> #include <string> using namespace std; int main () { int i; char data[30]; int int_arr[30]; printf("\nEnter the Data Bits to be transmitted :...

Display the number of the characters in a string

I have a Java question: I am writing a program to read a string and display the number of characters in that string. I found some example code but I don't quite understand the last part - can anyone help? int[] count = countLetters(line.toLowerCase()); for (int i=0; i<count.length; i++) { if ((i + 1) % 10 == 0) System.out.pri...

PHP String concatenation - "$a $b" vs $a . " " . $b - performance

Is there a speed difference between, say: $newstring = "$a and $b went out to see $c"; and $newstring = $a . " and " . $b . " went out to see " . $c; and if so, why ? ...

Simple way to convert a string to a dictionary

What is the simplest way to convert a string of keyword=values to a dictionary, for example the following string: name="John Smith", age=34, height=173.2, location="US", avatar=":,=)" to the following python dictionary: {'name':'John Smith', 'age':34, 'height':173.2, 'location':'US', 'avatar':':,=)'} The 'avatar' key is just to sho...

How to split strings on carriage return with C#?

Hi, I have an ASP.NET page with a multiline textbox called txbUserName. Then I paste into the textbox 3 names and they are vertically aligned: Jason Ammy Karen I want to be able to somehow take the names and split them into separate strings whenever i detect the carriage return or the new line. i am thinking that an array might be t...

parsing argc and argv in c++

I want to learn more C++... Usually I make a for loop to parse argv, and I wind up with a bunch a C-style strings. I want to do something similar in C++, but preferably without reading from /proc/whatever. At first, I tried to convert the C-style string to a C++ style string without results... The frustrating bit is that everyone on SO...

Finding a fuzzy match with bitap algorithm

Reciently I've looked through several implementation of bitap algorithm but what all of them do is finding the beginning point of fuzzy match. What I need is to find a match. There's an example: Say we have following text: abcdefg and a pattern: bzde and we want to find all occurence of a pattern in text with at most 1 error (Edit d...

Why doesn't this for-loop let me input text the first cycle?

What I want to do is ask the user for a number of strings to read into an array, and then ask the user to input that number of strings and read them into the array. When I run this code it never asks me for an input the first cycle of the first for-loop, just prints out "String #0: String #1: " and then I can input text. Why is that and ...

How to obtain an unformatted string representation of an NSDecimal or NSDecimalNumber?

I have an NSDecimal and need this as technical string, i.e. with no formatting in any way. Floating point should be a "." if there is any, and minus sign should just be a "-" if there is any. besides that, there should be no formatting going on like grouping or chinese numbers. I was looking for 2 hours through the SDK but it seems ther...

Constant string arrays

Is it possible to have a (fixed) array which stores its elements in the read-only segment of the executable and not on the stack? I came up with this code but unfortunately it is very unflexible when it comes to adding, moving or deleting items. How do I verify that the strings are indeed stored in the read-only segment? I tried readelf ...

how do i get an always changing value from a string c#

I am working on a program that will automatically get your characters stats and whatnot from the wow armory. I already have the html, and i can identify where the string is, but i need to get the "this.effective" value, which in this case is 594. But since its always changing (and so are the other values, i cant just take it a certain po...

best way to determine lower/uppercase in PHP?

I have a string that is one of the following forms ABC // all caps: // not necessarily "ABC", could be any combination of capital letters Abc // first letter capitalized, rest are lowercase abc // all lowercase and I need to distinguish which of these three cases it is... what's the best way to do this? There doesn't seem to ...

Python: How to get StringIO.writelines to accept unicode string?

I'm getting a UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 34: ordinal not in range(128) on a string stored in 'a.desc' below as it contains the '£' character. It's stored in the underlying Google App Engine datastore as a unicode string so that's fine. The cStringIO.StringIO.writelines function is t...