string-manipulation

C++: Read from text file and separate into variable.

I have this in a text file: John 20 30 40 mike 30 20 10 How do i read from the text file and separate them into variable name, var1, var2, var3. This is my attempt, seems it doesnt work. Help please. #include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; int main () { string name,result; ...

how to merge or inject "@" character in a string including escape characters without definning the string varibale from scratch in C#

hi , I have 2 related questions. 1)suppose we have: string strMessage="\nHellow\n\nWorld"; console.writeln(strMessage); Result is: Hellow World Now if we want to show the string in the original format in One Line we must redefine the first variable from scratch. string strOrignelMessage=@"\nHellow\n\nWorld" ; co...

How to remove periods in a string using jQuery

I have the string R.E.M. and I need to make it REM So far, I have: $('#request_artist').val().replace(".", ""); ...but I get RE.M. Any ideas? ...

Extract region and replace them back for a template

I have a template where I want to replace certain regions. In my example below, I want to extract the regions between the ... comments, manipulate it, then replace them back after the manipulation. I do not need the logic to merge the fields, but I need to extract the regions so I can use my logic and place it back into the template. ...

Ruby: Hash Assignment/Parse from Text

Looking to create a hash table from a text output that looks like this (whitespace between words are tabs): GCOLLECTOR 123456 77889 uno BLOCK unique111 error fullunique111 ... ... ... DAY ... ... ... LABEL detail unique111 Issue Broken - The truck broke LABEL detail ...

How to RegEx replace regions into a collection

I have a string that I want to extract text between comment tags, manipulate it, and replace it back. Here is what I am trying to work with: ... <!--RegionStart url="http://domain1.com"--&gt; some text here <!--RegionFinish--> ... <!--RegionStart url="http://domain2.com"--&gt; some text there <!--RegionFinish--> ... <!--RegionSt...

How do I finish a reverse string?

So my teacher told me to make a string that makes whatever I type go in the opposite order (e.g. "hello there" becomes "ereht olleh"). So far I worked on the body and I came up with this public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { (The input needs to be in...

Easiest way of working with a comma separated list

I'm about to build a solution to where I receive a comma separated list every night. It's a list with around 14000 rows, and I need to go through the list and select some of the values in the list. The document I receive is built up with around 50 semicolon separated values for every "case". How the document is structured: "";"2010-10-1...

Comparison of 2 text files: what and where changes were made?

Hi, imagine you have 2 texfiles (let's say 500kB - 3 MB large): the first is original, the second is the update of this original. How can I find out, what was changed (inserted, deleted) and where the changes took place (in the update file in comparison to original)? Is there any tool or library somewhere? Resides this function in an...

How to print a list with a different separator from the comma?

I keep on copy-pasting the following in my programs. I'm wondering if anyone of you uses similar code, perhaps in a library to achieve the same. @Override public String toString() { String ret = prefix; boolean first = true; for (Component child : children) { if (!first) { ret += " " + separator + " "; ...

How do I split a till receipt using a Regular Expression?

The last time I used a regular expression was 2 years ago and even then it wasn't something I considered to be the simplest of things! Could anybody tell me how I would go about splitting this text into three groups (qty, name, price)? 1 Corn Dog 5.00 3 Corn Dog 15.00 @ 5.00 2 Diet Cola 4.00 ...

How do I derive specific data from a string using the Java standard API?

I have the following pattern: Jan(COMPANY) &^% Feb(ASP) 567 Mar(INC) I want the final output to be: String[] one = {"Jan", "Feb", "Mar"}; String[] two = {"COMPANY","ASP","INC"}; Please help. Anyone!!? ...

How to remove duplicate white spaces in string using Java?

How to remove duplicate white spaces(including tabs,newlines,spaces,etc...) in a string using Java? ...

How many specified chars are in a string ?

taken a string example as 550e8400-e29b-41d4-a716-446655440000 how can one count how many - chars are in such string? I'm currently using: int total = "550e8400-e29b-41d4-a716-446655440000".Split('-').Length + 1; Is there any method that we don't need to add 1... like using the Count maybe? All other methods such as Contains IndexO...

How to safely split strings?

When we want to split a sting for any kind of reasons, we (at least myself) tend to split using the (pipe) | character as it is very rare to find out someone or that the application uses it on a string ... but what happens if it uses? Well, a simple Crash will be thrown :) I found out that a college uses non-printable chars to do the s...

LINQ way of transforming "TheQuickBrownFox" into "The quick brown fox"

Hi all, I am trying to transform a string made of words starting with an uppercase letter. I want to separate each word with a space and keep only the first uppercase letter. All other letters should be lowercase. For example, "TheQuickBrownFox" would become "The quick brown fox". Obviously, I could use a simple foreach and build a st...

Read to right of specific symbol in file from Python

I'm going to separate over 1000 virus signatures and the virus names. I have them all in a text file, and would like to do this with python. Here is the format: virus=signature I need to be able to take 'virus' and write it to one file, then take 'signature' and write it to another. This is what I've tied so far: h = open("FILEW...

PHP: How to quickly split a key=value file into associative array

When you send a PDT transaction ID back to paypal, you get back a list of transaction data. It has SUCCESS on the first line, and then a list of key=value pairs. One pair per line. For example: SUCCESS [email protected] charset=windows-1252 custom= first_name=Alice handling_amount=0.00 invoice=NN0005 item_name=Bear item_number...

Fundamentals and maths required for algorithms

I have been working on RTOS and Linux driver development for quite some time. Now I am interviewing at semiconductor companies and failing to answer questions about algorithms on strings, and time and space complexity. I have not studied discrete maths and algorithms during my as I have an electronics background. How can I overcome thi...

I'm trying to write a function for postgresql to do some string manipulation...

The purpose of the function is to take a string and, if it contains parens, delete everything in the parens. Here's what I have: CREATE FUNCTION clearmethodparams(IN qname text) RETURNS text AS $BODY$ IF position($o$($o$ in qname) = 0 THEN return qname; ELSE return substring(qname from 0 for position($p$($p$ in qn...