61
votes
7answers
90k views

How do I split this string with JavaScript?

I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the fastest way to parse this into var name = "john smith"; var street= "123 Street"; //etc...
2
votes
2answers
533 views

String with array structure to Array

I have string: Main.Sub.SubOfSub And some kind of data, may be a string: SuperData Also I have an empty array: $k = array(); How I can transform it all to this array above? Array ( [Main] ...
11
votes
5answers
2k views

C - Difference between “char var[]” and “char *var”?

I am expecting that both following vectors have the same representation in RAM: char a_var[] = "XXX\x00"; char *p_var = "XXX"; But strange, a call to a library function of type f(char argument[]) ...
10
votes
6answers
3k views

Difference between char *str=“STRING” and char str[] = “STRING”?

While coding a simple function to remove a particular character from a string, I fell on this strange issue: void str_remove_chars( char *str, char to_remove) { if(str && to_remove) { ...
13
votes
3answers
28k views

How can I split a comma delimited string into an array in PHP?

I need to split my string input into an array at the commas. How can I go about accomplishing this? Input: 9,[email protected],8
80
votes
7answers
116k views

How to convert object array to string array in Java

I use the following code to convert an Object array to a String array : Object Object_Array[]=new Object[100]; // ... get values in the Object_Array String String_Array[]=new ...
29
votes
6answers
96k views

How to add new elements to an array?

I have the following code: String[] where; where.append(ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1"); where.append(ContactsContract.Contacts.IN_VISIBLE_GROUP + "=1"); Those two appends are ...
22
votes
4answers
4k views

Check if multiple strings exist in another string

How can I check if any of the strings in an array exists in another string? Like: a = ['a', 'b', 'c'] str = "a123" if a in str: print "some of the strings found in str" else: print "no strings ...
5
votes
5answers
6k views

How to parse JSON in iOS App

Im getting a response from twitter in the form of a string, What I need is to send the parts where is a comment to an array, here an example of the string ...
146
votes
4answers
40k views

Ruby: what does %w(array) mean?

I'm looking at the documentation for FileUtils. I'm confused by the following line: FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6' What does the %w mean? Can you point me to the ...
20
votes
4answers
16k views

Access random item in list

I have an ArrayList, and I need to be able to click a button and then randomly pick out a string from that list and display it in a messagebox. How would I go about doing this? Any help at all is ...
4
votes
7answers
504 views

Question about pointers and strings in C [duplicate]

Possible Duplicate: What is the difference between char s[] and char *s in C? Difference between char *str = “…” and char str[N] = “…”? I have some code that has had me puzzled. #include ...
0
votes
4answers
8k views

PHP get values from SimpleXMLElement array

I have this: [1]=> object(SimpleXMLElement)#6 (1) { ["@attributes"]=> array(14) { ["name"]=> string(5) "MySQL" ["acknowledged"]=> string(1) "1" ["comments"]=> ...
1
vote
1answer
206 views

convert string to number array in matlab

I have a script in which a string of number is entered string='123' or string='9823' I am trying to convert this into an array of the form [a,b,c,d] e.g from a string of '123' to a numerical ...
24
votes
61answers
17k views

Language showdown: Convert string of digits to array of integers? [closed]

I was trying to convert a string containing only base 10 digits (e.g. "124890") to an array of corresponding integers (for given example: [1, 2, 4, 8, 9, 0]), in Ruby. I'm curious about how easily ...

1 2 3 4 5 17
15 30 50 per page