Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.erje.net!newsfeed.utanet.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Newsgroups: comp.lang.java.programmer From: Andreas Leitgeb Subject: Re: Confusion about String.matches method References: <50016a00-9422-46d4-8278-619fedafff55@c41g2000yqm.googlegroups.com> Reply-To: avl@logic.at User-Agent: slrn/pre0.9.9-111 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: Date: 31 May 2011 21:26:44 GMT Lines: 17 NNTP-Posting-Host: gamma.logic.tuwien.ac.at X-Trace: 1306877204 tunews.univie.ac.at 60386 128.130.175.3 X-Complaints-To: abuse@tuwien.ac.at Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4820 laredotornado wrote: >> > String regEx = "^Starting at \\$32,000*$"; >> String regEx = "^Starting at \\$32,000\\*$"; > > Is there a way I can match an arbitrary string without having to > escape everything? Yes: String text = "Starting at $32,000*"; ... if ("Starting at $32,000*".equals(text)) { // ^^^^^^^^^^^^^^^^^^^^-no special escapes needed here ;-) } If all you want is an exact match, then regexes are nothing but a nuissance for *that* task.