Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: regex reserved chars Date: Fri, 08 Feb 2013 19:02:39 -0800 Organization: A noiseless patient Spider Lines: 39 Message-ID: References: <42t5h8d8ta5iq9nkfded0pvfl104cqhc77@4ax.com> <511300de$0$295$14726298@news.sunsite.dk> <5115a135$0$288$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 9 Feb 2013 03:02:10 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="fba3415ba68d85d643935af2f52f0b4b"; logging-data="3900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lQlodAu4W3iS8a81BIVce+HgTv8+Oi7k=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: <5115a135$0$288$14726298@news.sunsite.dk> Cancel-Lock: sha1:cSe8BXKTKTfUnNpbLRCsHgDHljg= Xref: csiph.com comp.lang.java.programmer:22238 On 2/8/2013 5:06 PM, Arne Vajhøj wrote: > On 2/7/2013 4:17 PM, Martin Gregorie wrote: >> That's normally the first place I look, but it doesn't answer Roedy's >> question - > > Actually it does explain that the special characters are different > inside and outside. > ... > It did not answer the next question: what is the special > characters inside. I had to double-check this myself, but it does indeed answer the question. The section on character classes lists all the special character classes; they even order them by precedence for you. They are: 1. Literal escape: \ 2. Grouping: [] 3. Range: - (as in a-z) 4. Union (implicit): [a-e][i-o] 5. Intersection: && That's it. The "note" there just to remind you that this list is in fact distinct from the previous meta characters. (It appears to me that ^ actually makes a separate token with [, [^, which is different from the non-negated character class. That's why you can use ^ anywhere within the character class except the first position.) And BTW, by "double check," I mean I read the Pattern Java docs page. That's also a skill any programmer should have: reading. All the docs, to the end. It's just something you have to do.