Bittle icon

TrimExample.java

Bittle | PRO | 04/07/17 07:04:13 AM UTC | 0 ⭐ | 1171 👁️ | Never ⏰ | []
Java |

660 B

|

None

|

0 👍

/

0 👎

/**
 * Created by Oscar on 3/8/17.
 */
public class Test {
    public static void main(String[] args) {
        String incomingMessage = "!sysmsg [email protected] [email protected] All the rest of the text    here";
 
        String[] arr = incomingMessage.split("\\s+");
        if (arr.length < 4) {
            System.out.println("not a sysmsg");
            return;
        }
 
        String iWantThisText = arr[1];
        String thisText = arr[2];
        String andThisText = incomingMessage.substring(incomingMessage.indexOf(thisText) + thisText.length() + 1);
 
        System.out.println(iWantThisText + "\n" + thisText + "\n" + andThisText);
 
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎