string

convert an hex string to a NSData

How can I convert a string in hex format to retrieve from it an NSData and after that an UIImage inside of my iPhone app? I've got a string (str) that contains a value like X'FFD8FFE000104A46....01010000010001000'. That string is created from a xml file by the method: - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)st...

String class in specific languages

I'm becoming more interested in API's and was about starting to write my own, but then I was thinking a bit about the standard library of Java. The standard library of Java has a String class with tons of methods, isn't this bad design? I mean, if I would create a new instance of the String class, it would create an object with dozens o...

Replace last word in string

$variable = 'put returns between paragraphs'; Value of this variable everytime changes. How to add some text before the last word? Like, if we want to add 'and', the result should be (for this example): $variable = 'put returns between and paragraphs'; ...

Insert a string into a string given an index

Hi, I know this is a really simple question, but I was just wondering if there is a native php method to inject a string into another string. My usual response to a new text manipulation is to consult the manual's listings of string functions. But I didn't see any native methods for explicitly inserting a string into another string so ...

Replace char in a string

how to change [email protected] into XXX_YYY_ZZZ One way i know is to use the string.replace(char, char) method, but i want to replace "@" & "." The above method replaces just one char. one more case is what if i have [email protected]... i still want the output to look like XX.X_YYY_ZZZ Is this possible?? any suggestions thanks ...

Limited string replacement using regex?

Is it possible to use regex to only replace X number of occurrences of a particular string? For example, if I have the word 'lion' in a string 10 times, could I use regex to only replace the first 6 occurences instead of all of them? ...

Add before and after the string

$variable = 'for linebreak add 2 spaces at end'; Value of this variable everytime changes. How to add some text or html before and after this string? E.g. if we want to add '<div>' before and '</div>' after, string should look like: $variable = '<div>for linebreak add 2 spaces at end</div>'; ...

replace last part of a string in directory address

i have this as a string that shall come in - C:\abe\123-anb\porl\xyz.gif I want to replace the xyz.gif with abe.zip how can i do this in vb? ...

How to compare percentages that are strings?

I have a string "+1.29%" or "-1.29%" How can I convert this into a float or double so I can compare the values? This is how my comparator class looks like: package org.stocktwits.helper; import java.util.Comparator; import org.stocktwits.model.Quote; public class PercentChangeComparator implements Comparator<Quote> { ...

PHP string concatenation problem?

function formatUpdate($tweet,$dt,$picture,$username) { if(is_string($dt)) $dt=strtotime($dt); $tweet=htmlspecialchars(stripslashes($tweet)); $at = "@" . $username; return' <li> <a href="nano.com/' . $username . '"><img class="avatar" src="images/' . $picture . '" width="48" height="48" alt="avatar" /></a...

Best way to find multiple phrases in string?

Hi I want to process a String, in which I want to find multiple strings, i am trying to make some highlighter in html text in java.. Example: Find and process phrases table, row, primary key in Each table row contains a primary key column The text is html text with tags like <b>,<img..>... if there is ignorable tag in the middle of phras...

How can I quote a long string in Perl?

I usually use simple quotes, but sometime I get very long lines which I can't break and also need to use escape characters, so I get something like this: my $str = "select query_accession,query_tag,hit_accession,hit_tag,significance from summaryTables where query_id = \'$query_id\';" I know there are various other ways for representin...

Why does Perl complain about a syntax error during compilation of my program with this HTML string?

I am facing a problem in my code. Whenever I try to insert a text field then it's giving an error. What's wrong in the syntax here? print '<table>'; print "<tr style='background-color:#CDC9C9;'> <td><A HREF=\"http://localhost/cgi-bin/AddUser.cgi\"&gt;ADD&lt;/A&gt;&lt;/td&gt; <td></td> <td><b>UserId</b></td> <td><input type="text" ...

Out of string space in VisualBasic

When performing the replace operation over a string I got an error: 'out of string space' ...

How do i break an in-string variable in php?

This should be simple to answer. When I have a variable, say $id, and in a string, I want it between two underlines. Something like this: $id = 1; $myString = "row_$id_info"; Now, php will see "row_" and the variable $id_info - And that's not what I want. So my question is plain: How do i break an in-string variable in php? Thanks f...

Why does this code produce "syntax error, unexpected '='" ?

$text . = '1 paragraph'; $text . = '2 paragraph'; $text . = '3 paragraph'; echo $text; This code gives error syntax error, unexpected '='. What is the problem? ...

Regular Expression (Python) to extract strings of text from inside of < and > - e.g. <stringone><string-two> etc...

I'm currently playing with the Stack Overflow data dumps and am trying to construct (what I imagine is) a simple regular expression to extract tag names from inside of < and > characters. So, for each question, I have a list of one or more tags like <tagone><tag-two>...<tag-n> and am trying to extract just a list of tag names. Here are...

PHP: Seperate one field in two.

As many recommend me to seperate firstname and lastname instead of "full_name" with everything in, how can i seperate them to each variables, so if you example type in the field: "Dude Jackson" then "dude" gets in $firstname and Jackson in the $lastname. ...

gnuplot plot from string

Is it possible to pass to plot data in a string? I mean do something like this: plot "09-13-2010,2263.80 09-14-2010,2500" using 1:2 with lines ...

c++ - escape special characters

I need to escape all special characters and replace national characters and get "plain text" for a tablename. string getTableName(string name) My string could be "šárka65_%&." and I want to get string I can use in my database as a tablename. ...