string

How remove blank characters from a string in javascript?

How I could remove blank characters from a string in javascript? A trim is very easy, but I don't know how extract a blank "inside" the string. For example "222 334" -> "222334" Thanks in advance ...

JYaml refuses to cast a number as a string, regardless of quotes or !!str

Hi everyone! Has anyone else had a problem with JYaml 1.3 where on Yaml.load it is casting a number (like 102) as an Integer, even if you put it in quotes? For example, here's a small snippet from my yaml file: . . . listValues: "102": Joe "101": John . . . The 102 and 101 get constructed into the object created by Yam...

What is the concatenation complexity of balanced ropes?

I've looked at different papers and here is the information that I've gathered: SGI implementation and C cords neither guarantee O(1) time concatenation for long ropes nor ~log N depth for shorter ones. Different sources contradict each other. Wikipedia claims O(1) concatenation. This page says that concatenation is O(1) only when one ...

Remove entire word if the word contains specific string

I would like to do the following, preferably with PHP: Remove an entire word if a part of the word contains a specific string. This should be case insensitive and work multiple times, e.g. on a large text. Pseudo-code: match = "www." lots_of_random_text = "... hello and welcome to www.stackoverflow.com! blah blah" result = magic_functi...

[Python] Open file into array, search for string and return value

Alright, I've been working on this for a while and cannot get it. I'm making a method that accepts a filename, and a pattern. E.g findPattern(fname, pat) Then the goal is to look for that pattern, say the string "apple" within the text file that is opened, and return it's location by [line, beginning character index] I'm new to python...

C++ replace multiple strings in a string in a single pass

Hi, Newbie here. Given the following string, "Hi ~+ and ^*. Is ^* still flying around ~+?" I want to replace all occurrences of "~+" and "^*" with "Bobby" and "Danny", so the string becomes: "Hi Bobby and Danny. Is Danny still flying around Bobby?" I would prefer not to have to call Boost replace function twice to replace the occurr...

Proper way to build up a path using cstrings in C++

I need to build up a path to a file. I have the following class method: void Directory::scanDirectory(char *directory) { DIR *dirp; struct dirent *entry; char path[1]; if(dirp = opendir(directory)) { while(entry = readdir(dirp)) { if (entry->d_name[0] != '.') { strcpy(path, directory)...

C# Determing whether any element in a string array contains a given string anywhere

I have a string array: string[] Animals = {"Cat", "Dog", "Fish"}; I then want to determine which element contains the sequence "is" and return that entire element; in this case "fish" If I want to find "gh", it does not exist in the list, so it should return the first element, in this case "Cat" I've tried this linq code, but i don'...

How do I stop a stored procedure or ASP page from corrupted unicode strings?

I have a database that has already corrupted unicode strings, now on my ASP page, they are shown as "?" marks. Is there a way either to stop them from being returned down at the stored procedure level? or is the best way to stop them from showing up on the asp page is to somehow detect the corrupted unicode strings and stop them from bei...

Split string of 2 words in separate words [but sometimes there is only word in the string...]

I have strings like "AMS.I-I.D. ver.5" and "AM0011 ver. 2", of which the "ver. *" needs to be stripped. I have done that with: (^A.*)(ver.\s\d{1,2}) The problem occurs when there is no version number like "AM0003". How can I make the (ver.\s\d{1,2}) part optional? ...

Is it possible to use NBuilder to Build a collection of random strings?

Hi Folks, pretty simple question: can I use NBuilder to create a collection of x number of random strings? I was trying... // NOTE: Tags need to be lowercase. return Builder<string> .CreateListOfSize(10) .WhereAll() .Has(x => x = randomGenerator.Phrase(15)) .WhereTheFirst(1) .Has(x => x = "time") .AndTh...

converting string into multidimensional array

hi, I'd like to convert this string: $credit_packages_string = "300,0.25|1000,0.24|3000,0.22|4000,0.20|5000,0.18|6000,0.16|7000,0.14"; into this array: $credit_packages = array( array( 'credit_amount'=> 300, 'price_per_credit'=>0.25), array( 'credit_amount'=> 1000, 'price_per_credit'=>0.24), array( 'credit...

C++ program does not work on some inputs

Hallo I have this assignment to print only alphabets in a C++ string. It works for most input but when [ and ] are present in the input they are printed as well. #include <iostream> #include <string> using namespace std; int main() { string input = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG]"; for(int i=0;i<input.s...

BATCH FILE to remove duplicate strings containing Double Quotes; and keep blank lines

BATCH FILE to remove duplicate strings (containing Double Quotes); and keep blank lines Note: The Final Output must have original strings with Double Quotes and Blank lines. I have been working on this for a long time and I can not fine a solution, thanks in advance for your assistance. When I get the remove duplicates working somethin...

Performance comparison of immutable string concatenation between Java and Python

UPDATES: thanks a lot to Gabe and Glenn for the detailed explanation. The test is wrote not for language comparison benchmark, just for my studying on VM optimization technologies. I did a simple test to understand the performance of string concatenation between Java and Python. The test is target for the default immutable String obj...

Specify Array from Command Line Argument

I realize that each argument passed from the command line is stored as a string in 'char *argv[]' I'd like to pass $ progname array[500] and pull the string from argv[1] subsequently specifying an array based on what I read in. Any ideas? ...

strcpy() and arrays of strings

I need to store the input from a user into an array of strings. #include <stdlib.h> #include <stdio.h> #include <string.h> char *history[10] = {0}; int main (void) { char input[256]; input = "input"; strcpy(history[0], input); return (EXIT_SUCCESS); } Running it on the terminal I get a Segmentation Fault and in ...

C++ String Array, Loading lines of text from file

I have a problem. When I try to load a file into a string array nothing shows. Firstly I have a file that on one line has a username and on the second has a password. I haven't finished the code but when I try to display what is in the array nothing displays. I would love for this to work. Any suggestions? users.txt user1 password use...

Super Simple Android Help: Change Image on Correct Password

So I am a complete newb, and am currently taking an intro to Mobile Programming course in which we use Android (I have some experience with Java). I am trying to do a simple assignment which displays a text field and an image, and upon entering the correct "password" and pressing enter, the image changes. Should be so simple! But I am ...

replace text in a string with .net regexp

Hello, I try to use regexp in .net to find and replace strings with certain token, example myString = "this is a example of my text that I want to change <#somevalue#> and <#anothervalue#>" How I can find the text with tokens between "<#" and "#>" and for each of those, do something to replace it (search on a database and replace any o...