-4

Hello all i am having a fun filled irritating little problem which i am sure can be resolved in less than 5 seconds with the enlightened and combined minds of stack overflow users

ok first off it seems i am having trouble communicating what my trouble is with the gentlemen and ladies who are trying to help me in earlier posts

so i am going to make it very simple

i need to get 337 and 229 out of this son of satan string that is constantly updating every 2 seconds now i dont know how to go about doing this i know i should probably use split but i dont know how to do it on this because i have very little experience with it

Last login: Thu Jun 5 08:20:35 2014 from .** /*/*-..****.**///*-****.**.*/****/*/***status Virtual server [...] is UP. *: 337 bananas left ****(s)******: 229 bananas eaten(s) ** *. [* ] –

i am tired and would like to finish this before i am gray or sentanced to prison for raving naked down my street please help and thanks in advance

p.s dont really care if this gets down voted a bit tired and more than a little angry so enjoy

Wolf
  • 170
  • 1
  • 4
  • 19
  • Regex is your friend. – Mats Jun 05 '14 at 09:17
  • i know @matthias but my brain power is at a all time low as in im reverting back to a primitive please how would you go about doing this? – Wolf Jun 05 '14 at 09:18
  • String temp = "Last login: Thu Jun 5 08:20:35 2014 from .** /*/*-..****.**///*-****.**.*/****/*/***status Virtual server [...] is UP. *: 337 bananas left ****(s)******: 229 bananas eaten(s) ** *. [* ] –"; String[] arr = temp.Split(new String[]{"*:"}, StringSplitOptions.RemoveEmptyEntries); String numOne = arr[1].Split(new String[]{" "}, StringSplitOptions.RemoveEmptyEntries)[0]; String numTwo = arr[2].Split(new String[]{" "}, StringSplitOptions.RemoveEmptyEntries)[0]; String tmp = ""; – IrishGeek82 Jun 05 '14 at 09:23
  • The problem is, SO is not a service for writing some code for you. If you are tired - get some rest and get back when you feel better. There's not enough information in this question, so voting to close (e.g. it would be nice to know if string format is fixed and what are those asterisks are) – J0HN Jun 05 '14 at 09:24
  • 1
    @IrishGeek82 thank you very much i appreciate your help glad to know that there are people that wish to help instead of just spewing random junk – Wolf Jun 05 '14 at 09:25
  • cant defulge the information but it is pulled through ssh the * is letters and numbers – Wolf Jun 05 '14 at 09:25
  • 2
    @Wolf, sadly, people don't quite understand what being a mentor means. I've searched high and low on SO for things before only to be confronted with copious negative responses such as "did you google it" (when in fact, a google search brought me to the post in the first place). Good luck! – IrishGeek82 Jun 05 '14 at 09:26
  • @IrishGeek you have it right i appreciate your help alot thank you have a awesome day il be deleting this post because it seems my personality has offended some sensitive geusts aka -3 LOL – Wolf Jun 05 '14 at 09:27
  • 2
    @IrishGeek82 There's a little difference between helping to do one's job and doing it yourself, nicely summarized in [this proverb](http://en.wiktionary.org/wiki/give_a_man_a_fish_and_you_feed_him_for_a_day;_teach_a_man_to_fish_and_you_feed_him_for_a_lifetime). you have asked/answered a particular question, applicable for this situation only, while SO aims to provide answers to questions many could face. I'm not trying to mentor or lecture you, but you both could do better that that. – J0HN Jun 05 '14 at 09:33
  • @IrishGeek82 i know give a man a fish and his belly is full for a night but teach a man to fish and his belly is full every night ,i know how to fish i just needed bait for this specific fish and you supplied it i have inserted code above that shows how i get my string it may be of help to you so you can understand where my string comes from – Wolf Jun 05 '14 at 09:41
  • 1
    I gave the man a fishing pole and taught him to fish. Basic as it is, that is where you start. You not only did not give the man a fish, you gave him a cold shoulder. This simple issue I just got through covering in another typical SO response http://stackoverflow.com/questions/24055675/how-to-replace-with-comma-in-javascript#comment37090754_24055675 . Which was considered duplicate of this post http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript which was viewed 262226. You may not find this question userful to others. But someone will:) – IrishGeek82 Jun 05 '14 at 09:45

1 Answers1

1
    String temp = "Last login: Thu Jun 5 08:20:35 2014 from .** /*/*-..****.**///*-****.**.*/****/*/***status Virtual server [...] is UP. *: 337 bananas left ****(s)******: 229 bananas eaten(s) ** *. [* ] –";
    String[] arr = temp.Split(new String[]{"*:"}, StringSplitOptions.RemoveEmptyEntries);
    String numOne = arr[1].Split(new String[]{" "}, StringSplitOptions.RemoveEmptyEntries)[0];
    String numTwo = arr[2].Split(new String[]{" "}, StringSplitOptions.RemoveEmptyEntries)[0];
    String tmp = "";

I'm putting it here in the answer so it is formatted well.

This is not pretty, it is completely rudimentary, and very much a kludge but it works.

IrishGeek82
  • 355
  • 2
  • 8