string-manipulation

unwanted quote marks in output from printf

I have some address data which has been exported from a database. If the address had multiple lines, the exported data has joined all the lines into one string with the former lines being separated by dollars signs. Here's one of the addresses: INFORMATION DELIVERY DEPT$704 CHERRY ST$ATLANTA, GA 30332-0900 I'm splitting this into an ...

Tear subString from within HTML tags with JAVA

Hi! let say i have a string like this "neverMind<b>What is up</b>neverMind" and I want to take out the What is up using regexp with JAVA. Someone told me that using matcher will be the best. Can anyone show me how to do it using Matcher? Other solutions are welcome too! Thanks! ...

Javascript string replace with calculations

Is there a way to resolve mathematical expressions in strings in javascript? For example, suppose I want to produce the string "Tom has 2 apples, Lucy has 3 apples. Together they have 5 apples" but I want to be able to substitute in the variables. I can do this with a string replacement: string = "Tom has X apples, Lucy has Y apples. To...

Removing text in all kinds of braces

Hi, I have a string "hello [world] this {is} a (test)" I want to remove all text in braces, e.g. returning "hello this a". But only if the braces match. Anyone have a nice neat solution? ...

String Manipulation in C

Hi guys, I am helping my nephew for his C lab homework, it is a string manipulation assignment and applying Wang's algorithm. Here is the BNF representation for the input. <s> ::= <l> # <r> <l> ::= <list>| ε <r> ::= <list>| ε <list> ::= <f>|<f> , <list> <f> ::= <letter>| - <f>| (<f><op><f>) <op> ::= & | | | > <letter> ::= A |... | Z ...

sql: aggregate functions & string join / concatenation

(I'm using postgres) Are there any aggregate functions that work on strings? I want to write a query along the lines of select table1.name, join(' - ', unique(table2.horse)) as all_horses from table1 inner join table2 on table1.id = table2.fk group by table1.name Given these 2 tables: | table1 | | table2 ...

Count the number of lines in a Java String

Need some compact code for counting the number of lines in a string in Java. The string is to be separated by \r or \n. Each instance of those newline characters will be considered as a separate line. For example, "Hello\nWorld\nThis\nIs\t" should return 4. The prototype is private static int countLines(String str) {...} Can someo...

split a string based on pattern in java - capital letters and numbers

Hi all I have the following string "3/4Ton". I want to split it as --> word[1] = 3/4 and word[2] = Ton. Right now my piece of code looks like this:- Pattern p = Pattern.compile("[A-Z]{1}[a-z]+"); Matcher m = p.matcher(line); while(m.find()){ System.out.println("The word --> "+m.group()); } It carries out the needed task of ...

What should I call the operation that limits a string's length?

This is a language-agnostic question - unless you count English as a language. I've got this list of items which can have very long names. For aesthetic purposes, these names must be made shorter in some cases, adding dots (...) to indicate that the name is longer. So for example, if article.name returns this: lorem ipsum dolor sit am...

Format String become xxx1, xx10 or 1###, 10## etc

Hi all, I have following numbers : 1, 2, 3, 4, 10 But I want to print those numbers like this: 0001 0002 0003 0004 0010 I have searched in Google. the keyword is number format. But I've got nothing, I just get, format decimal such ass 1,000,000.00. I hope you can suggest me a reference or give me something to solve this problem. ...

parse this directory path without losing slash

hi, I have a wxPython application. I am taking in a directory path from a textbox using GetValue(). I notice that while trying to write this string to a variable: "C:\Documents and Settings\tchan\Desktop\InputFile.xls", python sees the string as 'C:\\Documents and Settings\tchan\\Desktop\\InputFile.xls' (missing a slash between "...

Subscript text in pdf C#

How do I insert a subscript charachter in a string in C#? I have nor problems appending a superscript 2 in the same string using char.ConvertFromUtf32(178);, but I struggle with finding a similar solution for the subscripted text. Actually, I'm struggling with finding ANY solution at all to this rather embarrassing issue. :) ...

C#: What's the best way to delete empty lines from a multiline string?

In C# what's the best way to remove blank lines i.e., lines that contain only whitespace from a string? I'm happy to use a Regex if that's the best solution. EDIT: I should add I'm using .NET 2.0. ...

VB.Net Split A Group Of Text

I am looking to split up multiple lines of text to single them out, for example: Url/Host:ftp://server.com/1 Login:Admin1 Password:Password1 Url/Host:ftp://server.com/2 Login:Admin2 Password:Password2 Url/Host:ftp://server.com/3 Login:Admin3 Password:Password3 How can I split each section into a different textbox, so tha...

whats wrong with strcpy()

What is wrong with strcpy() in this code? void process_filedata(char *filename) { void* content; const char * buffer; char * temp; char * row; char * col; int lsize,buflen,tmp,num_scan; //num_scan - number of characters scanned int m=0,p=0,d=0,j=0; //m - machine, p - phase, d- delimiter, j - job FILE *file_pointer = fop...

Efficient way in Python to add an element to a comma-separated string

I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words: For example: string = 'Apples, Bananas, Grapes, Oranges' addition = 'Cherries' result = 'Apples, Bananas, Cherries, Grapes, Oranges' Also, a way to do this but while maintaining IDs: string = '1:Ap...

How can I trim certain characters from a string in sql?

I would like to trim all special characters from a string in SQL. I've seen a bunch of people who use substring methods to remove a certain amount of characters, but in this case the length on each side of the string is unknown. Anyone know how to do this? Thanks, Matt ...

weird characters in my generated PDF

I'm getting characters in my PDF, i've stripped out \r\n \r \n \t, trimmed everything, decoded html entities and stripped tags. Nothing helps. The data is coming from a MySQL database. Any help would be appreciated. ...

Efficient way in Python to remove an element from a comma-separated string

I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words: For example: string = 'Apples, Bananas, Grapes, Oranges' subtraction = 'Bananas' result = 'Apples, Grapes, Oranges' Also, a way to do this but while maintaining IDs: string = '1:Apples, 4:Bananas, ...

C# delete space from variable

My variable looks like: name = "Lola "; // notice the whitespace How can I delete the whitespace at the end to leave me with just "Lola"? Thank you all, but .Trim() don't work to me. I read the text from a file, if that is any help. ...