string

Explode function in C++.

I am new to programming. I have been trying to write a function in C++ that explodes the contents of a string into a string array at a given parameter, example: string str = "___this_ is__ th_e str__ing we__ will use__"; should return string array: cout << stringArray[0]; // 'this' cout << stringArray[1]; // ' is' cout << stringArra...

hw search substring in a list of indexed strings?

i am implementing dictionary in which key is a string keyword.suppose i have following keys in dictionary. mat**hon** sat**hon** lat**hon** now if i serach single keyword suppose mathon it will search it in constant time.but if i am to search hon i want all of three words to be retreived in constant time or minimum time possible like...

Strings and file

Hello, Suppose this is my list of languages. aList = ['Python','C','C++','Java'] How can i write to a file like : Python : ... C : ... C++ : ... Java : ... I have used rjust() to achieve this. Without it how can i do ? Here i have done manually. I want to avoid that,ie; it shuould be ordered automati...

How do I optimize this method for breaking a string in chunks?

Here's the method. I want to know if I am violating any best practices here or if I am doing something wrong as far as the language is concerned. private List<String> breakStringInChunks(String text, int chunkSize) { List<String> chunks = new ArrayList<String>(); String temporary = ""; int numberOfChunks = text.l...

.net OutOfMemory exception

While making some final tests of a class-library that I'm writing for Windows Mobile (using Compact Net Framework 2.0), I ran into an OOM-exception. Basically, my library loads first a dictionary-file (an ordinary text file with a word list) and thereafter another file based upon the dictionary (I call it KeyMap) which size is more or ...

How to identify if string contain a number?

hi if I have this strings: "abc" = false "123" = true "ab2" = false Is there any command like IsNumeric or something else that can identify if string has numbers? thank's in advance ...

How to replace occurrences of "-" with an empty string?

Hi I have this string: "123-456-7" I need to get this string: "1234567" How I can replace occurrences of "-" with an empty string? Thanks in advance ...

How fast is String.Substring relative to other methods of string processing?

I'm using VB.NET to process a long fixed-length record. The simplest option seems to be loading the whole record into a string and using Substring to access the fields by position and length. But it seems like there will be some redundant processing within the Substring method that happens on every single invocation. That led me to wonde...

How to get the number of times a string is repeated in PHP

In a string like "abc fox fox fox ghi xyz" how can i get the number of times 'fox' is repeated in the string? ...

What is wrong in my concatenation function mystrcat(char*, char*, char*) ?

I was interviewed recently and asked to write mystrcat(*s1, *s2, *s3) where s1 and s2 are source string and the concatenated results are given by s3. I was told, don't worry about memory allocation of s3 and assume s1 and s2 are not null / invalid strings. So I wrote the following lame (crude) program. I was told there is something wrong...

Best way to do a split and convert the result into ints

I have a DB table that contains a comma separated list of ID's (ints) that are stored as nvarchar. I have a get method to return these in one hit as a list. At the moment I think I'll have to do something like this: List<int> ids = new List<int>(); string[] pageids = experssion.Split(separators) foreach (string number in pageids) {...

How to implement a SQL like 'LIKE' operator in java?

I need a comparator in java which has the same semantics as the sql 'like' operator. For example: myComparator.like("digital","%ital%"); myComparator.like("digital","%gi?a%"); myComparator.like("digital","digi%"); should evaluate to true, and myComparator.like("digital","%cam%"); myComparator.like("digital","tal%"); should evaluate...

Is there an easy way to iterator over a static list of strings in C++

It often happens that I need to iterate over a list of strings in my C++ code. In languages like Perl, this is easy: foreach my $x ("abc", "xyz", "123") {.... } In the past, this is what I've done in C++ const char* strs[] = { "abc", "xyz", "123" }; for (int i=0; i<sizeof(strs)/sizeof(const char*); i++) { const char *str = strs[i...

how do I elegantly format string in C++ so that it is rounded to 6 decimal places and has extra '0's or '9's trimmed

How do I write a function that formats a string with decimals digits, without trailing 0's or unnecessary 9's? Given that decimals is 2, here's what I expect: 0.999 -> 1.0 0.99 -> 0.99 1.01 -> 1.01 1.001 -> 1.0 123 -> 123.0 0 -> 0.0 0.1 -> 0.1 (negatives as you'd expect) Here's what I have so far, but it's pretty ugly code. Is ther...

Is there a high-level way to read in lines from an output file and have the types recognized by the structure of the contents?

Suppose I have an output file that I want to read and each line was created by joining several types together, prepending and appending the list braces, [('tupleValueA','tupleValueB'), 'someString', ('anotherTupleA','anotherTupleB')] I want to read the lines in. Now I can read them in, and operate on the string to assign values and ...

comparing strings in vb

hi, hopefully this should be an easy question. In java i know it's compareto, i think. how do i compare 2 string variables to determine if they are the same? ie: if(string1 = string2 AND string3= string 4) then perform operation else perform another operation end if Thanks ...

Mapping a list of Enums

I have a table called UserPermissions with a FK to the users table by userId and then a string column for the string value of an enum. The error I am seeing is NHibernate.MappingException: An association from the table UserPermissions refers to an unmapped class: GotRoleplay.Core.Domain.Model.Permission My Permission Enum: public ...

Is there any way to extract text from a Flash-based website?

I'd like to code a scrobbling utility for Grooveshark using Last.FM's API but I don't know if it's possible to get the song information from the Grooveshark's Flash frontend. Is there any way to get strings from a .swf? I'd post some more information but I'm not able to post links yet since I'm a new user. ...

Split SMS gateway answer in PHP

Hi I am wondering what other approaches you would take to do some simple string splitting in PHP. I am receiving a response from a SMS gateway where two of the interesting values are the code used and the users text message. The code could be something like: Freetrip (lowercase, uppercase, mixed case) The user message should in the be...

MySQL Replace characters in every table and column of a database

Hello I'd like to replace a string in every column and every table of a specific database. Is there a way to do this ? Thanks in advance :) Edit: That is because I have spotted Gibberish at some locations and it will take me days to fix it one by one ...