![]() |
regex reserved chars
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 |
Re: regex reserved chars
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? |
Re: regex reserved chars
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 |
Re: regex reserved chars
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+express...haracter+class HTH -- Lew |
Re: regex reserved chars
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+express...haracter+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.) |
Re: regex reserved chars
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 |
Re: regex reserved chars
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+cla ss 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 |
Re: regex reserved chars
On Wed, 06 Feb 2013 16:28:29 -0800, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted someone who said : >ve always treated $ ( ) * + -. ? [ \ ] ^ { | } >as reserved regex chars. >I can't find any docs that say the list is different inside[ ]. I have not found an official source however it is claimed only [ - ^] are reserved in character classes i.e inside [...] I don't think that can be right. Surely $ is reserved too, and of course \. -- 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 |
Re: regex reserved chars
On Thursday, February 7, 2013 8:31:47 AM UTC+1, Roedy Green wrote:
> On Wed, 06 Feb 2013 16:28:29 -0800, Roedy Green > > <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted > someone who said : > > >ve always treated $ ( ) * + -. ? [ \ ] ^ { | } > >as reserved regex chars. > >I can't find any docs that say the list is different inside[ ]. > > I have not found an official source however it is claimed only [ - ^] > are reserved in character classes i.e inside [...] Is http://docs.oracle.com/javase/6/docs...x/Pattern.html not official enough? Or are you missing an more explicit explanation on that page? > I don't think that can be right. Roedy, why??? > Surely $ is reserved too, and of course \. Dot has no special meaning and neither does $. Btw. you can easily test that. Apart from that dot with special meaning does not make sense in a character class if you think about it for a moment. Cheers robert |
Re: regex reserved chars
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. |
| All times are GMT. The time now is 06:26 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.