The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Java input parsing by dennismv 2007-10-22 18:31:05
I'm trying to parse a statement like "344+33" into 3 parts: number, operation + - * / and another number. So far it does not work. Any Java-fluent UFies in the house ?

import java.*; import java.io.*; import java.util.regex.Pattern; public class Main {     public static void main(String [] args)     {         //Declarations         //Calculator calc=new ProxyCalculator();         //Scanner cin = new Scanner(System.in);         Pattern p = Pattern.compile("(\\d*)([+\\-\\*/])(\\d*)");             String[] sargs = p.split("344+33");             System.out.println(sargs[0]);         System.out.println(sargs[1]);         System.out.println(sargs[2]);     } }

[ Reply ]
  Check out the StringTokenizer class (n/t) by archnerd2007-10-22 18:35:16
  What are you getting instead? by fudje2007-10-22 18:36:25
    I'm getting by dennismv2007-10-22 18:38:28
  You're using Pattern.split wrong by Talchas2007-10-22 18:44:13
    See, this is why I like Perl. by fudje2007-10-22 18:53:11
      yep by dennismv2007-10-23 17:59:03
    Yeah, that's what I was thinking, too. by jdelphiki2007-10-22 20:03:13
  If it's going to get any more complicated than by Arachnid2007-10-22 18:47:08
  I'm sorry, my brain won't let me not do this. by salmar2007-10-22 19:27:42
  b*ches !! by dennismv2007-10-23 18:13:21

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)