🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8615

Re: Parsing a string expresion

#8615
From: Torsten Welches
Date: Mon, 12 Mar 2001 06:31
15 lines
1480 bytes
"Francisco Correa" <constru01@interpla.net.co> wrote:
>I want to know how can I parse a string expresion as "=2+3" to 
>a Double value using Java 1.3

that depends on how complicated the string expression can get.
If the second and fourth characters are always 1-digit numbers 
and the third is always an arithmetic operator it would be quite
easy with String.charAt, Integer.valueOf and so on. 
If the structure can get more complicated (e.g. more then one 
arithmetic operator) you need to tokenize before you parse.
java.text.BreakIterator or java.io.StreamTokenizer look like they
could be helpful for this.

Torsten
Technical Details
Message-ID: <3aac6d56$1_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!207.105.83.65
References: <3aaa5c4c_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b7c8aed305deb19
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-11 22:38:09 PST
From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Sender: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Reply-To: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Subject: Re: Parsing a string expresion
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 193.158.55.74 193.158.55.74    
References:  <3aaa5c4c_2@dnews> 
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3aac6d56$1_2@dnews>
Date: 11 Mar 2001 22:31:50 -0800
X-Trace: 11 Mar 2001 22:31:50 -0800, 207.105.83.65
Lines: 15
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!207.105.83.65