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 dennismv2007-10-22 18:31:05
  You're using Pattern.split wrong by Talchas2007-10-22 18:44:13
    Yeah, that's what I was thinking, too. by jdelphiki 2007-10-22 20:03:13
Though I'm not sure that using Pattern/Matcher to get these is the best of all possible solutions.

If it's a simple parser, looking only for the basic math operators, using the StringTokenizer or indexOf to find the operator and break apart the string would be simpler and would run less risk of coming across a scenario that breaks the regex pattern.

If it's supposed to be a bulletproof math parser, one would need to use some kind of linked list or, better, a recursive tree class to parse the equation. Otherwise, things like parentheses and operator hierarchy come into play and make it too complicated for a basic pattern match.
[ Reply ]

 

[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.)