string

Java - How to split a string on plus signs?

Hi! I was trying to split an arithmetic expression (eg "1+2+10+15") on the plus signs. However, I didn't manage to write the appropriate regular expression. I thought this would work: expression.split("\\+"); but it doesn't. Do you know the correct solution? ...

String.trim(); How does it work?

If I've got string like that: " content ". Will String.trim() remove all spaces on these sides or just one space on each? ...

How do I turn a dictionary into a string?

params = {'fruit':'orange', 'color':'red', 'size':'5'} How can I turn that into a string: fruit=orange&color=red&size=5 ...

Pex and "\0" what is the correct name for this?

I am using Pex and keeps throwing "\0" at my string parameters. Through a little testing I found that it is some sort of end of string? I am looking for the official name for this to learn more about it but google is shallowing all the white spaces of "\0" making it a 0 and end of string does not turn up much either. Interstingly the ...

Repeat while changing... stop once change no longer occurs i.e. stabilise value.

I was wondering if there is a nice pattern or better yet a specific function which applies a function until there is no longer a change in it's result. url = "http://www.zzz.com/yyy/lt%255B1%255D.jpg" unescaped = unescape(url) while unescaped != url do url = unescaped unescaped = unescape(unescaped) end Although the code above is ...

Include constant in string without concatenating

Is there a way in PHP to include a constant in a string without concatenating? ...

How do I put variable values into a text string in MATLAB?

I'm trying to write a simple function that takes two inputs, x and y, and passes these to three other simple functions that add, multiply, and divide them. The main function should then display the results as a string containing x, y, and the totals. I think there's something I'm not understanding about output arguments. Anyway, here's ...

JavaScipt: Unicode space character

I want to insert the space character into the innerHTML of a DOM element, but the space character must be declare in unicode syntax. For exxample, something like this: ...innerHTML += '\u83838383'; ...

How do I strip spaces out of data in a SharePoint column?

I have a MOSS 2007 list with a column which contains hundreds of business and city names. These names are text commonly with multiple words, such as "City of Austin". I have setup filtering and data view web parts to allow a page to display contents of the list based on a query string. All works well, except that I need to generate th...

Is there a way to turn XML into dictionary and lists?

<things> <fruit>apple</fruit> <hardware>mouse</hardware> ... </things> Turn it into: {'things':[{'fruit':'apple'}, {'hardware':'mouse'}]} Is there an easy way to do this? Thanks. ...

save and load data (iphone sdk)

hi all i'm wondering what's the best method to save and load data in a iphone application. i'm trying to save strings into a text file or something like that and load them into a table view, so that the first entry in the text file is the first row in the table view and so on... somebody got an idea how I could realize that? thanks i...

Remove substrings in ruby

Given an array of strings, array1 = ["abcdwillbegoneabcccc","cdefwilbegokkkabcdc"] and another array of strings which consist of patterns e.g. ["abcd","beg[o|p]n","bcc","cdef","h*gxwy"] the task is to remove substrings that match any of the pattern strings. for example a sample output for this case should be: ["willbegonea","wilbeg...

Print string in a form of Unicode codes

How can I print a string as a sequence of unicode codes in Python? Input: "если" (in Russian). Output: "\u0435\u0441\u043b\u0438" ...

Highlighting current page in the nav

Hi I need to highlight the current page in my left nav. The nav has to be loaded externally via an .shtml include: <!--#include file="leftnav-menu.inc"--> My urls take the form of: www.xxx.com/mission-critical.shtml but sometimes just: www.xxx.com/energy.shtml (eg one word no hyphen) My nav lists it as 'Mission critical' How ca...

convert font to string and back again

Hello, i have an application where my user changes font and font color for different labels etc and they save it to a file but i need to be able to convert the font of the specified label to a string to be written to file, and then when they open that file my program will convert that string back into a font object. How can this be done...

php string add tag (modify)

I got from a json feed this : <img src = "http://produits-lemieux.com/produits/bainmoussant_hg.jpg" ></img> i need to inject alt="" into the string Best method to do that in php ? ...

How do I pass a static method to comp in clojure?

It seems as though I'm having problems accessing Integer.parseInt in comp. I can access it normally like this: user=> (Integer/parseInt "123") 123 But if I put it in comp, I get an error: user=> (def vect-to-int (comp Integer/parseInt (partial apply str))) java.lang.Exception: Unable to find static field: parseInt in class java.lang...

Mnemonic Password Generation Algorithm for QWERTY Keyboards

I've a "mnemonic" password generation function that goes something like this: function Mnemonic($mnemonic) { $result = null; $charset = array(str_split('aeiou', 1), str_split('bcdfghjklmnpqrstvwxyz', 1)); for ($i = 1; $i <= $mnemonic; $i++) { $result .= $charset[$i % 2][array_rand($charset[$i % 2])]; } ...

How to write the C# prototype to P/Invoke a function which takes a char* as an argument, and returns its value there.

As the title suggests, I'm trying to write some C# code to interop with a C DLL (It's a Windows device driver, basically). The error code function signature in C is: UINT DLLErrorMsg( DWORD errorCode, char * pBuf, UINT nSize ); nSize is the size of pBuf. If nSize can fit the error message, it is copied into pBuf and 0 returned, othe...

BASH: Test whether string is valid as an integer?

Hello All, I'm trying to do something common enough: Parse user input in a shell script. If the user provided a valid integer, the script does one thing, and if not valid, it does something else. Trouble is, I haven't found an easy (and reasonably elegant) way of doing this - I don't want to have to pick it apart char by char. I know t...