Advertisement
Bittle

TrimExample.java

Apr 7th, 2017
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. /**
  2.  * Created by Oscar on 3/8/17.
  3.  */
  4. public class Test {
  5.     public static void main(String[] args) {
  6.         String incomingMessage = "!sysmsg jid@talk.com otherjid@talk.com All the rest of the text    here";
  7.  
  8.         String[] arr = incomingMessage.split("\\s+");
  9.         if (arr.length < 4) {
  10.             System.out.println("not a sysmsg");
  11.             return;
  12.         }
  13.  
  14.         String iWantThisText = arr[1];
  15.         String thisText = arr[2];
  16.         String andThisText = incomingMessage.substring(incomingMessage.indexOf(thisText) + thisText.length() + 1);
  17.  
  18.         System.out.println(iWantThisText + "\n" + thisText + "\n" + andThisText);
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement