Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 38668 invoked from network); 15 Apr 2009 12:40:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Apr 2009 12:40:28 -0000 Received: (qmail 66883 invoked by uid 500); 15 Apr 2009 12:40:26 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 66770 invoked by uid 500); 15 Apr 2009 12:40:26 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 66760 invoked by uid 99); 15 Apr 2009 12:40:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Apr 2009 12:40:26 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jacek99@gmail.com designates 74.125.92.147 as permitted sender) Received: from [74.125.92.147] (HELO qw-out-1920.google.com) (74.125.92.147) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Apr 2009 12:40:18 +0000 Received: by qw-out-1920.google.com with SMTP id 5so2016537qwc.60 for ; Wed, 15 Apr 2009 05:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Nj8rF7WBgCvmwiUP+DBGfqRa5KFOw8xALiU4a8ZdAOA=; b=vXDvbIl/Xi7T10FSfbjPPWV8I8KA2LsQu1pbnX6UEYyoJaYPasvyJ6eWi1EbF+mrjt CbLUpH4FDhgowF9y77/bSvfoW8ovfSctql/71dNoQ79DMRjh66jrcjuGSmZstcZlSrbr gzJRI7ga8I1JykvasgvBhDuVesdfob3o4W5ZM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=tPV5Ja9gJ/WEwiUzrDp3+BLscRNMoMg5yH8yClc+BLjWtU3nj53LuV15wPGjg0QgFz LzOcZcjq0+2Rqfxx0eAQoUJqjRc50la8KnDH103xTc8E8KHlqS2BMH4mTo/p7YyrV1oE lNQl7Rqo3i3Jjm3eiWhA3Od08MRSd6M1hj3UQ= MIME-Version: 1.0 Received: by 10.220.92.21 with SMTP id p21mr27921vcm.47.1239799197244; Wed, 15 Apr 2009 05:39:57 -0700 (PDT) Date: Wed, 15 Apr 2009 08:39:57 -0400 Message-ID: <269a5c30904150539rc3bc48fw364252b8bf7d9996@mail.gmail.com> Subject: StrTokenizer not handling quotes correctly? From: Jacek Furmankiewicz To: user@commons.apache.org Content-Type: multipart/alternative; boundary=0016e6470ecebec7080467973e8a X-Virus-Checked: Checked by ClamAV on apache.org --0016e6470ecebec7080467973e8a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I am trying to use StrTokenizer for some parsing and I am probably not using it correctly. Let's say I have this string: 11"a,b"11,22"c,d"22" I would like to split it by the comma ",", but ignoring any commas embedded in quotes. I try this: String test = "11\"a,b\"11,22\"c,d\"22"; StrTokenizer str = new StrTokenizer(test,',','"'); String[] tokens = str.getTokenArray(); for(String t: tokens) { System.out.println(t); } and expect to have two strings print out: 11"a,b"11 22"c,d"22 but instead I get 4 : 11"a b"11 22"c d"22 It seems the tokenizer is splitting on the comma, even if it is embedded in quotes. I tried different options on the StrTokenizer, but not been able to get it to work correctly. Any idea as to what am I doing wrong? Using latest version 2.4. Thanks, Jacek --0016e6470ecebec7080467973e8a--