string

Python how to search and correct html tags and attributes?

I have to fix all the closing tags of the <img> tag as shown in the text below. Instead of closing the <img> with a >, it should close with />. Is there any easy way to search for all the <img> in this text and fix the > ? (If it is closed with a /> already then there is no action required). Other question, if there is no "width" or "...

MySQL Match Against query does not work with Urlencoded string

This is the table. CREATE TABLE `posts` ( `post_id` int(20) NOT NULL AUTO_INCREMENT, `post_archived` enum('Y','N') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'N', `post_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `post_author` int(20) NOT NULL DEFAULT '0', `post_date` timestamp NOT NULL D...

Access an array and get the stringvalue of an element...

Hi, i would like to know how i can access the name of an image when the syntax is something like that: NSArray* imgArray =[[NSArray alloc] initWithObjects: [UIImage imageNamed:@"test_01.png"], [UIImage imageNamed:@"test_02.png"], [UIImage imageNamed:@"test_02.png"], nil]; If i print out a specific index, i get the ad...

DataSet column can be NULL but not converted to string ?

I have a string which can be empty if its not empty it is containing a xml document. The problem is null values are allowed in this dataset column of DataType System.String. Error Message:this.MetaData' threw an exception of type 'System.Data.StrongTypingException' base {System.SystemException} = {"The value for column 'MyData' in tabl...

Large Numeric Value Conversion issue...

Hello...I have a large text string number (20 characters, no decimals) that needs to be converted to a number. I tried Convert.ToInt64 but the value is too large. What is the best conversion method for a number this large? And, what is the actual max value for Convert.ToInt64()? Thanks ...

How to convert list of strings to doubles?

EDIT : I had tried these two ways before - List doubleList = stringList.ConvertAll(x => (double)x); List doubleList = stringList.Select(x => (double)x).ToList(); and got this error- Cannot convert type 'string' to 'double' I read about something similiar that convert ints to doubles...but I have List of st...

Is encapsulating Strings as byte[] in order to save memory overkill ? (Java)

Was recently reviewing some Java Swing code and saw this: byte[] fooReference; String getFoo() { returns new String(fooReference); } void setFoo(String foo) { this.fooReference = foo.getBytes(); } The above can be useful to save on your memory foot print or so I'm told. Is this overkill is anyone else encapsulating their St...

howto extract simple string from tuple in python (newbie question)

I have a rather large tuple which contains: [('and', 44023), ('cx', 37711), ('is', 36777) .... ] I just want to extract the first string delimited by the single quotes, so the output for the above tuple would be: and cx is How do I code this (with extensibilty built in to some degree)? ...

Efficiently carry out multiple string replacements in Python

If I would like to carry out multiple string replacements, what is the most efficient way to carry this out? An example of the kind of situation I have encountered in my travels is as follows: >>> strings = ['a', 'list', 'of', 'strings'] >>> [s.replace('a', '')...replace('u', '') for s in strings if len(s) > 2] ['a', 'lst', 'of', 'st...

Non destructive split in Ruby

I want to split the string "hello+world-apple+francisco-rome", into ["hello", "+world", "-apple", "+francisco", "-rome"]. String::split actually loses the splitting element. Anyone can do that? ...

How to parse xml and loop through it from a string ?

I want parse xml by looping through it. I referred this but I am not able to parse it using the Load function since it expects an URI parameter and not a string and so does LINQ to XML....Can anyone help me out ? ...

Split text using strtok without deleting the delim c++

How can I split a text into tokens using strtok without deleting the delim? I want just to split at their place. ...

How to find URLs in HTML using Java

I have the following... I wouldn't say problem, but situation. I have some HTML with tags and everything. I want to search the HTML for every URL. I'm doing it now by checking where it says 'h' then 't' then 't' then 'p', but I don't think is a great solution Any good ideas? Added: I'm looking for some kind of pseudocode but, just i...

Find string between two substrings

How do I find a string between two substrings ('123STRINGabc' -> 'STRING')? My current method is like this: >>> start = 'asdf=5;' >>> end = '123jasd' >>> s = 'asdf=5;iwantthis123jasd' >>> print((s.split(start))[1].split(end)[0]) iwantthis However, this seems very inefficient and un-pythonic. What is a better way to do something like ...

Read string enclosed in double quotes from text file

I have a text file that contains a data like ID Name Path IsTrue Period 1 "1 yr" "C:\\Program Files\\My File.xyz" -1 2" 1 "1 yr" "C:\\Program Files\\My File.xyz" -1 2" now I have the following code to split the l...

String Cleaning in C#

I am trying to write a function that as input takes a string containing words and removes all single character words and returns the new string without the removed characters E.g.: string news = FunctionName("This is a test"); //'news' here should be "This is test". Can you please help? ...

Replacing accented characters php

I am trying to replace accented characters with the normal replacements. Below is what I am currently doing. $string = "Éric Cantona"; $strict = strtolower($string); echo "After Lower: ".$strict; $patterns[0] = '/[á|â|à|å|ä]/'; $patterns[1] = '/[ð|é|ê|è|ë]/'; $patterns[2] = '/[í|î|ì|ï]/'; $patterns[3] = '/[...

How can I generate a random English "sounding" word in .Net?

I know there have been several posts about random word generation based on large dictionaries or web lookups. However, I'm looking for a word generator which I can use to create strong password without symbols. What I'm looking for is a reliable mechanism to generate a random, non recognised, English word of a given length. An example ...

Java - Get child nodes as a string

Is it possible to get the child nodes under an xml element/node as a string in Java? Or do you have iterate through everything? Thanks, Andez ...

XSL QUESTION: alternative method to count the number of lines or newline characters of an xml attribute

I've scoured the internet to discover this method of finding the number of lines in an xml element.: <xsl:if test="string-length(@Example) - string-length(translate(@Example, '&#xa;', '')) &lt; 10"> In the example above, @Example is the element for which the number of lines is counted. I didn't like this code, however, because it aut...