Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #22182 > unrolled thread
| Started by | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| First post | 2013-02-06 16:28 -0800 |
| Last post | 2013-02-08 20:02 -0500 |
| Articles | 20 on this page of 26 — 9 participants |
Back to article view | Back to comp.lang.java.programmer
regex reserved chars Roedy Green <see_website@mindprod.com.invalid> - 2013-02-06 16:28 -0800
Re: regex reserved chars markspace <markspace@nospam.nospam> - 2013-02-06 16:54 -0800
Re: regex reserved chars Lew <lewbloch@gmail.com> - 2013-02-06 18:03 -0800
Re: regex reserved chars markspace <markspace@nospam.nospam> - 2013-02-06 18:10 -0800
Re: regex reserved chars Roedy Green <see_website@mindprod.com.invalid> - 2013-02-06 22:50 -0800
Re: regex reserved chars markspace <markspace@nospam.nospam> - 2013-02-07 09:32 -0800
Re: regex reserved chars Gene Wirchenko <genew@telus.net> - 2013-02-07 10:51 -0800
Re: regex reserved chars markspace <markspace@nospam.nospam> - 2013-02-07 11:53 -0800
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:25 -0500
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:32 -0500
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:17 -0500
Re: regex reserved chars Roedy Green <see_website@mindprod.com.invalid> - 2013-02-06 23:06 -0800
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:15 -0500
Re: regex reserved chars Lew <lewbloch@gmail.com> - 2013-02-09 10:43 -0800
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-06 20:18 -0500
Re: regex reserved chars Martin Gregorie <martin@address-in-sig.invalid> - 2013-02-07 21:17 +0000
Re: regex reserved chars Jim Janney <jjanney@shell.xmission.com> - 2013-02-07 20:47 -0700
Re: regex reserved chars Martin Gregorie <martin@address-in-sig.invalid> - 2013-02-09 00:50 +0000
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:06 -0500
Re: regex reserved chars markspace <markspace@nospam.nospam> - 2013-02-08 19:02 -0800
Re: regex reserved chars Nigel Wade <nmw@ion.le.ac.uk> - 2013-02-11 09:25 +0000
Re: regex reserved chars markspace <markspace@nospam.nospam> - 2013-02-11 07:16 -0800
Re: regex reserved chars Nigel Wade <nmw@ion.le.ac.uk> - 2013-02-11 17:12 +0000
Re: regex reserved chars Roedy Green <see_website@mindprod.com.invalid> - 2013-02-06 23:31 -0800
Re: regex reserved chars Robert Klemme <shortcutter@googlemail.com> - 2013-02-07 04:38 -0800
Re: regex reserved chars Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:02 -0500
Page 1 of 2 [1] 2 Next page →
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-02-06 16:28 -0800 |
| Subject | regex reserved chars |
| Message-ID | <42t5h8d8ta5iq9nkfded0pvfl104cqhc77@4ax.com> |
I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
as reserved regex chars.
I can't find any docs that say the list is different inside[ ].
is it?
--
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development
time.
~ Tom Cargill Ninety-ninety Law
[toc] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-02-06 16:54 -0800 |
| Message-ID | <keutvu$7ot$1@dont-email.me> |
| In reply to | #22182 |
On 2/6/2013 4:28 PM, Roedy Green wrote:
> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
> as reserved regex chars.
> I can't find any docs that say the list is different inside[ ].
> is it?
>
<http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html>
"Note that a different set of metacharacters are in effect inside a
character class than outside a character class. For instance, the
regular expression . loses its special meaning inside a character class,
while the expression - becomes a range forming metacharacter. "
Learn to STFW.
I really hate to use language like that, but Jesus Roedy are you kidding me?
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-06 18:03 -0800 |
| Message-ID | <97897683-a69c-430a-a3de-90f2faeed82f@googlegroups.com> |
| In reply to | #22183 |
markspace wrote:
> Roedy Green wrote:
>> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
>> as reserved regex chars.
>> I can't find any docs that say the list is different inside[ ].
>> is it?
>
> <http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html>
>
> "Note that a different set of metacharacters are in effect inside a
> character class than outside a character class. For instance, the
> regular expression . loses its special meaning inside a character class,
> while the expression - becomes a range forming metacharacter. "
>
> Learn to STFW.
>
> I really hate to use language like that, but Jesus Roedy are you kidding me?
http://lmgtfy.com/?q=Regular+expression+metacharacters+character+class
HTH
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-02-06 18:10 -0800 |
| Message-ID | <kev2ec$rdb$1@dont-email.me> |
| In reply to | #22185 |
On 2/6/2013 6:03 PM, Lew wrote: > markspace wrote: >> Learn to STFW. >> >> I really hate to use language like that, but Jesus Roedy are you kidding me? > > http://lmgtfy.com/?q=Regular+expression+metacharacters+character+class My point was that Roedy is a Java programmer post in a Java newsgroup, and he didn't even look at the existing Java docs for regex patterns. I just can't even conceive why Roedy would post such a question. I wasn't even going to post the lmgtfy link because the Java docs are such an obvious solution. That said the first link when I do Google is a really excellent discussion exactly how character classes and meta-characters work, with even different flavors of regex discussed (Posix is a bit different, the others seem the same.)
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-02-06 22:50 -0800 |
| Message-ID | <n5j6h85b0okgheov2c86mtfgdkutqticka@4ax.com> |
| In reply to | #22187 |
On Wed, 06 Feb 2013 18:10:45 -0800, markspace <markspace@nospam.nospam> wrote, quoted or indirectly quoted someone who said : >My point was that Roedy is a Java programmer post in a Java newsgroup, >and he didn't even look at the existing Java docs for regex patterns I spent 15 minutes looking and did not find it. You can argue that I should have, but the fact remains I did not. I did you no harm by asking a question. You are not obligated to answer it. The answer may be of general interest to people who never even thought to ask the question. If I asked you face to face you would not dream of answering that way. The problem is too MUCH irrelevant crap you have to wade through when you search. The answer to many such a question is simply the magic vocabulary that evokes the desired info. But you have to find the information to know the magic vocabulary. Catch 22. -- Roedy Green Canadian Mind Products http://mindprod.com The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ~ Tom Cargill Ninety-ninety Law
[toc] | [prev] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-02-07 09:32 -0800 |
| Message-ID | <kf0odn$59n$1@dont-email.me> |
| In reply to | #22190 |
On 2/6/2013 10:50 PM, Roedy Green wrote: > On Wed, 06 Feb 2013 18:10:45 -0800, markspace > <markspace@nospam.nospam> wrote, quoted or indirectly quoted someone > who said : > >> My point was that Roedy is a Java programmer post in a Java newsgroup, >> and he didn't even look at the existing Java docs for regex patterns > > I spent 15 minutes looking and did not find it. You can argue that I > should have, but the fact remains I did not. I really am not trying to be an ass (there's enough of that here already). But seriously I'm not kidding when I say the answer is literally the first link when I search. <https://www.google.com/search?q=regex+character+class> What the FIRST link when you use that search? > I did you no harm by > asking a question. You are not obligated to answer it. The answer > may be of general interest to people who never even thought to ask the > question. "STFW" is the answer, and it's of general interest. C.f. Eric Raymond's "How to Ask Questions the Smart Way," which says the same thing. > If I asked you face to face you would not dream of > answering that way. I certainly might. Learning how answer your own questions is part of your professional development; don't waste your colleagues' time with silly questions. There's a Dilbert cartoon about "time wasting morons." It's funny because "time wasting morons" are common enough to have a Dilbert about it. Don't be the time wasting moron. > The problem is too MUCH irrelevant crap you have to wade through when > you search. Not when I search, and so I have to conclude the same is true for you. > > The answer to many such a question is simply the magic vocabulary that > evokes the desired info. But you have to find the information to know > the magic vocabulary. Catch 22. > You used all the words you needed in your question. What "magic vocabulary" are you referring too? I get on your case Roedy because I know you've got enough experience that you should know these things already.
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2013-02-07 10:51 -0800 |
| Message-ID | <ldt7h8h3jhqck20o8kaokkiu8v092gm7cs@4ax.com> |
| In reply to | #22197 |
On Thu, 07 Feb 2013 09:32:01 -0800, markspace
<markspace@nospam.nospam> wrote:
>On 2/6/2013 10:50 PM, Roedy Green wrote:
>> On Wed, 06 Feb 2013 18:10:45 -0800, markspace
>> <markspace@nospam.nospam> wrote, quoted or indirectly quoted someone
>> who said :
>>
>>> My point was that Roedy is a Java programmer post in a Java newsgroup,
>>> and he didn't even look at the existing Java docs for regex patterns
>>
>> I spent 15 minutes looking and did not find it. You can argue that I
>> should have, but the fact remains I did not.
>
>I really am not trying to be an ass (there's enough of that here
>already). But seriously I'm not kidding when I say the answer is
>literally the first link when I search.
There is no guarantee that search results will be given in a
particular order.
><https://www.google.com/search?q=regex+character+class>
>
>What the FIRST link when you use that search?
<http://www.regular-expressions.info/charclass.html>
which is not
<http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html>
(the link you first posted).
Roedy is right about there being a lot to wade through. I got
About 3,790,000 results (0.22 seconds)
>> I did you no harm by
>> asking a question. You are not obligated to answer it. The answer
>> may be of general interest to people who never even thought to ask the
>> question.
>
>"STFW" is the answer, and it's of general interest. C.f. Eric Raymond's
>"How to Ask Questions the Smart Way," which says the same thing.
I have often done, been unable to find something of use, asked
people for links on what I needed and gotten very useful links.
>> If I asked you face to face you would not dream of
>> answering that way.
>
>I certainly might. Learning how answer your own questions is part of
>your professional development; don't waste your colleagues' time with
>silly questions. There's a Dilbert cartoon about "time wasting morons."
> It's funny because "time wasting morons" are common enough to have a
>Dilbert about it. Don't be the time wasting moron.
There are also Dilbert cartoons about people throwing hissy fits.
Don't do it.
>> The problem is too MUCH irrelevant crap you have to wade through when
>> you search.
>
>Not when I search, and so I have to conclude the same is true for you.
You did not get anywhere near 3,790,000 results?
>> The answer to many such a question is simply the magic vocabulary that
>> evokes the desired info. But you have to find the information to know
>> the magic vocabulary. Catch 22.
>You used all the words you needed in your question. What "magic
>vocabulary" are you referring too? I get on your case Roedy because I
>know you've got enough experience that you should know these things already.
Roedy was looking for "reserved regex chars". Your search uses
"regex character class". I would not have thought of that as it does
not seem to be what I would be looking for.
After one finds something, then it might be obvious then what to
search for. Until then, it is not. I have done searches for things
that I would have thought would be on the Net, but after trying many
different things, I have had to give up on it.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-02-07 11:53 -0800 |
| Message-ID | <kf10mj$pp0$1@dont-email.me> |
| In reply to | #22198 |
On 2/7/2013 10:51 AM, Gene Wirchenko wrote: > On Thu, 07 Feb 2013 09:32:01 -0800, markspace >> <https://www.google.com/search?q=regex+character+class> >> >> What the FIRST link when you use that search? > > <http://www.regular-expressions.info/charclass.html> Yup, that's the first link for me too. And it has the answer Roedy wants. > Roedy was looking for "reserved regex chars". Your search uses > "regex character class". I would not have thought of that as it does > not seem to be what I would be looking for. If you're looking for information about meta-characters in regex character classes, shouldn't that be obvious? At first I might try is something more specific, but after 12+ years of Google use, it's kind of obvious to also try a more general search word list. Trying out five or ten different searches does not take 15 minutes total, as Roedy claimed. Yes, I realize that some things are hard to search for, but this is certainly not one of them. And for me personally that was the first search I tried after reviewing the Java Pattern page. Also, I'm surprised no one has pointed this out. From the Java Pattern page: "For a more precise description of the behavior of regular expression constructs, please see Mastering Regular Expressions, 3nd Edition, Jeffrey E. F. Friedl, O'Reilly and Associates, 2006." Chris folks, it even points you at the very authoritative source you claim to be looking for. Did anyone ever try reading that book? SOME things on the web or in computer science are esoteric and hard to find more information on. This is not one of those things.
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:25 -0500 |
| Message-ID | <5115a571$0$288$14726298@news.sunsite.dk> |
| In reply to | #22198 |
On 2/7/2013 1:51 PM, Gene Wirchenko wrote: > On Thu, 07 Feb 2013 09:32:01 -0800, markspace > <markspace@nospam.nospam> wrote: > >> On 2/6/2013 10:50 PM, Roedy Green wrote: >>> On Wed, 06 Feb 2013 18:10:45 -0800, markspace >>> <markspace@nospam.nospam> wrote, quoted or indirectly quoted someone >>> who said : >>> >>>> My point was that Roedy is a Java programmer post in a Java newsgroup, >>>> and he didn't even look at the existing Java docs for regex patterns >>> >>> I spent 15 minutes looking and did not find it. You can argue that I >>> should have, but the fact remains I did not. >> >> I really am not trying to be an ass (there's enough of that here >> already). But seriously I'm not kidding when I say the answer is >> literally the first link when I search. > > There is no guarantee that search results will be given in a > particular order. > >> <https://www.google.com/search?q=regex+character+class> >> >> What the FIRST link when you use that search? > > <http://www.regular-expressions.info/charclass.html> > which is not > > <http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html> > (the link you first posted). But both explains what Roedy asked. The first link in Google search also answers the next question. > Roedy is right about there being a lot to wade through. I got > About 3,790,000 results (0.22 seconds) But since he did not have to wade through it, then it is not so relevant. >>> The problem is too MUCH irrelevant crap you have to wade through when >>> you search. >> >> Not when I search, and so I have to conclude the same is true for you. > > You did not get anywhere near 3,790,000 results? He probably did. But when the info was in the first then ... (it may not always turn up as the first but what so if it was #3) >>> The answer to many such a question is simply the magic vocabulary that >>> evokes the desired info. But you have to find the information to know >>> the magic vocabulary. Catch 22. > >> You used all the words you needed in your question. What "magic >> vocabulary" are you referring too? I get on your case Roedy because I >> know you've got enough experience that you should know these things already. > > Roedy was looking for "reserved regex chars". Your search uses > "regex character class". I would not have thought of that as it does > not seem to be what I would be looking for. Actually Roedy was not looking for reserved regex characters. He was looking for reserves characters in regex character class. [] is called character class. And that is in almost any regex documentation. http://mindprod.com/jgloss/regex.html#MULTIPLE have chosen to call them multiples, but ... Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:32 -0500 |
| Message-ID | <5115a731$0$291$14726298@news.sunsite.dk> |
| In reply to | #22198 |
On 2/7/2013 1:51 PM, Gene Wirchenko wrote: > On Thu, 07 Feb 2013 09:32:01 -0800, markspace > <markspace@nospam.nospam> wrote: >> On 2/6/2013 10:50 PM, Roedy Green wrote: >>> I did you no harm by >>> asking a question. You are not obligated to answer it. The answer >>> may be of general interest to people who never even thought to ask the >>> question. >> >> "STFW" is the answer, and it's of general interest. C.f. Eric Raymond's >> "How to Ask Questions the Smart Way," which says the same thing. > > I have often done, been unable to find something of use, asked > people for links on what I needed and gotten very useful links. > >>> If I asked you face to face you would not dream of >>> answering that way. >> >> I certainly might. Learning how answer your own questions is part of >> your professional development; don't waste your colleagues' time with >> silly questions. There's a Dilbert cartoon about "time wasting morons." >> It's funny because "time wasting morons" are common enough to have a >> Dilbert about it. Don't be the time wasting moron. > > There are also Dilbert cartoons about people throwing hissy fits. > Don't do it. It is perfectly fine for anyone new to Java to ask even relative simple questions that could be easily answered from standard documentation. And they should get links and explanations without any negative remarks. But that is not really the case here. Here we have a person (Roedy) that about 50 times per month claim to be Java knowledgeable by posting links to his web site as answer to questions. There is simply a conflict between asking questions that are explained in Java Docs and providing a web site with answers to Java questions. That conflict can be called out more or less elegant. Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:17 -0500 |
| Message-ID | <5115a3a9$0$288$14726298@news.sunsite.dk> |
| In reply to | #22190 |
On 2/7/2013 1:50 AM, Roedy Green wrote: > On Wed, 06 Feb 2013 18:10:45 -0800, markspace > <markspace@nospam.nospam> wrote, quoted or indirectly quoted someone > who said : > >> My point was that Roedy is a Java programmer post in a Java newsgroup, >> and he didn't even look at the existing Java docs for regex patterns > > I spent 15 minutes looking and did not find it. You can argue that I > should have, but the fact remains I did not. Maybe you should work on reading more careful. > The problem is too MUCH irrelevant crap you have to wade through when > you search. That type of sorting is basic skill for programmers. Arne
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-02-06 23:06 -0800 |
| Message-ID | <cnj6h89glj2398eerhhmrom18qtq5rm3u4@4ax.com> |
| In reply to | #22185 |
On Wed, 6 Feb 2013 18:03:56 -0800 (PST), Lew <lewbloch@gmail.com> wrote, quoted or indirectly quoted someone who said : >p://lmgtfy.com/?q=Regular+expression+metacharacters+character+class Did you check to see if the question is actually answered in there somewhere, or just that in any sane universe it should be? Some of that material I previously waded through without success. This question may be easier to answer with a set of experiments. -- Roedy Green Canadian Mind Products http://mindprod.com The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ~ Tom Cargill Ninety-ninety Law
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:15 -0500 |
| Message-ID | <5115a330$0$288$14726298@news.sunsite.dk> |
| In reply to | #22191 |
On 2/7/2013 2:06 AM, Roedy Green wrote: > On Wed, 6 Feb 2013 18:03:56 -0800 (PST), Lew <lewbloch@gmail.com> > wrote, quoted or indirectly quoted someone who said : > >> p://lmgtfy.com/?q=Regular+expression+metacharacters+character+class > > Did you check to see if the question is actually answered in there > somewhere, or just that in any sane universe it should be? You asked the question. So what about you check!!!! The first link I get has the info. Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-09 10:43 -0800 |
| Message-ID | <27908497-ab0f-4ecc-934b-4abd8ff1f5b9@googlegroups.com> |
| In reply to | #22230 |
Arne Vajhøj wrote: > Roedy Green wrote: >> Lew wrote, quoted or indirectly quoted someone who said : >>> http://lmgtfy.com/?q=Regular+expression+metacharacters+character+class > >> Did you check to see if the question is actually answered in there >> somewhere, or just that in any sane universe it should be? I always confirm and follow all links that I post before I press SEND. In addition I follow the search links, ensuring that the top three or four contain information pertinent to the question. Often I will spend some time reading the articles to which the search linked. I learn a lot doing that. > You asked the question. > > So what about you check!!!! > > The first link I get has the info. By offering a search link I'm able to provide much, much more information to the querent than anything I could condense myself into a post. Some people get mad, saying, "If I could have come up with those search terms I wouldn't have asked!" Exactly. But rather trivial, as that could be said about every question that comes up here. But you took an important first step, seeking help for your problem. My skill at providing search terms that will help you find your answers is my gift to you. You are most welcome. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-06 20:18 -0500 |
| Message-ID | <511300de$0$295$14726298@news.sunsite.dk> |
| In reply to | #22182 |
On 2/6/2013 7:28 PM, Roedy Green wrote:
> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
> as reserved regex chars.
> I can't find any docs that say the list is different inside[ ].
> is it?
Typical it is.
Regex syntax vary a bit between implementations.
So one should study the documentation.
java.util.regex.Pattern has an excellent JavaDoc.
Read it!
Arne
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2013-02-07 21:17 +0000 |
| Message-ID | <kf15kg$g9o$1@localhost.localdomain> |
| In reply to | #22184 |
On Wed, 06 Feb 2013 20:18:19 -0500, Arne Vajhøj wrote:
> On 2/6/2013 7:28 PM, Roedy Green wrote:
>> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
>> as reserved regex chars.
>> I can't find any docs that say the list is different inside[ ].
>> is it?
>
> Typical it is.
>
> Regex syntax vary a bit between implementations.
>
> So one should study the documentation.
>
> java.util.regex.Pattern has an excellent JavaDoc.
>
That's normally the first place I look, but it doesn't answer Roedy's
question - apart, that is, from referring to the dead tree O'Reilly book.
Expanding the 'Character Classes' description in the Pattern class-level
documentation or linking to an online source would be more useful than
the implied suggestion of buying the book from Amazon and then waiting
for delivery.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
[toc] | [prev] | [next] | [standalone]
| From | Jim Janney <jjanney@shell.xmission.com> |
|---|---|
| Date | 2013-02-07 20:47 -0700 |
| Message-ID | <ydnvca3eaac.fsf@shell.xmission.com> |
| In reply to | #22201 |
Martin Gregorie <martin@address-in-sig.invalid> writes:
> On Wed, 06 Feb 2013 20:18:19 -0500, Arne Vajhøj wrote:
>
>> On 2/6/2013 7:28 PM, Roedy Green wrote:
>>> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
>>> as reserved regex chars.
>>> I can't find any docs that say the list is different inside[ ].
>>> is it?
>>
>> Typical it is.
>>
>> Regex syntax vary a bit between implementations.
>>
>> So one should study the documentation.
>>
>> java.util.regex.Pattern has an excellent JavaDoc.
>>
> That's normally the first place I look, but it doesn't answer Roedy's
> question - apart, that is, from referring to the dead tree O'Reilly book.
> Expanding the 'Character Classes' description in the Pattern class-level
> documentation or linking to an online source would be more useful than
> the implied suggestion of buying the book from Amazon and then waiting
> for delivery.
I have a copy of that book, in an earlier edition, but I usually find it
more convenient to consult regular-expressions.info, e.g.
http://www.regular-expressions.info/charclass.html
which answers the question very nicely. It also explains things like
lookbehind that the JavaDoc only hints at.
--
Jim Janney
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2013-02-09 00:50 +0000 |
| Message-ID | <kf46g1$9fj$1@localhost.localdomain> |
| In reply to | #22203 |
On Thu, 07 Feb 2013 20:47:55 -0700, Jim Janney wrote:
> Martin Gregorie <martin@address-in-sig.invalid> writes:
>
>> On Wed, 06 Feb 2013 20:18:19 -0500, Arne Vajhøj wrote:
>>
>>> On 2/6/2013 7:28 PM, Roedy Green wrote:
>>>> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
>>>> as reserved regex chars.
>>>> I can't find any docs that say the list is different inside[ ].
>>>> is it?
>>>
>>> Typical it is.
>>>
>>> Regex syntax vary a bit between implementations.
>>>
>>> So one should study the documentation.
>>>
>>> java.util.regex.Pattern has an excellent JavaDoc.
>>>
>> That's normally the first place I look, but it doesn't answer Roedy's
>> question - apart, that is, from referring to the dead tree O'Reilly
>> book.
>> Expanding the 'Character Classes' description in the Pattern
>> class-level documentation or linking to an online source would be more
>> useful than the implied suggestion of buying the book from Amazon and
>> then waiting for delivery.
>
> I have a copy of that book, in an earlier edition, but I usually find it
> more convenient to consult regular-expressions.info, e.g.
>
> http://www.regular-expressions.info/charclass.html
>
> which answers the question very nicely. It also explains things like
> lookbehind that the JavaDoc only hints at.
Thanks for the URI. Added to my reference library.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:06 -0500 |
| Message-ID | <5115a135$0$288$14726298@news.sunsite.dk> |
| In reply to | #22201 |
On 2/7/2013 4:17 PM, Martin Gregorie wrote:
> On Wed, 06 Feb 2013 20:18:19 -0500, Arne Vajhøj wrote:
>
>> On 2/6/2013 7:28 PM, Roedy Green wrote:
>>> I have always treated $ ( ) * + -. ? [ \ ] ^ { | }
>>> as reserved regex chars.
>>> I can't find any docs that say the list is different inside[ ].
>>> is it?
>>
>> Typical it is.
>>
>> Regex syntax vary a bit between implementations.
>>
>> So one should study the documentation.
>>
>> java.util.regex.Pattern has an excellent JavaDoc.
>>
> That's normally the first place I look, but it doesn't answer Roedy's
> question - apart, that is, from referring to the dead tree O'Reilly book.
> Expanding the 'Character Classes' description in the Pattern class-level
> documentation or linking to an online source would be more useful than
> the implied suggestion of buying the book from Amazon and then waiting
> for delivery.
Actually it does explain that the special characters are different
inside and outside.
"Note that a different set of metacharacters are in effect inside a
character class than outside a character class. For instance, the
regular expression . loses its special meaning inside a character class,
while the expression - becomes a range forming metacharacter."
And that was Roedy's question.
"I can't find any docs that say the list is different inside[ ]. is it?"
It did not answer the next question: what is the special
characters inside.
Arne
[toc] | [prev] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-02-08 19:02 -0800 |
| Message-ID | <kf4e7i$3ps$1@dont-email.me> |
| In reply to | #22227 |
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.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web