Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28800

Re: Regex?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <eternal@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: Regex?
Date Fri, 20 Jun 2014 15:46:13 -0700
Organization A noiseless patient Spider
Lines 52
Message-ID <lo2dji$k7u$1@dont-email.me> (permalink)
References <lo0du6$os5$1@dont-email.me> <lo0fac$vgk$1@dont-email.me> <c0i5vfFqriiU1@mid.individual.net> <lo1im5$3ak$1@dont-email.me> <lo1j4g$6l6$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 20 Jun 2014 22:46:10 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="20734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IbuP7EKujy8qDKA73Owui"
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <lo1j4g$6l6$1@dont-email.me>
Cancel-Lock sha1:g2sV5phpqkCkVvg522O6buAHqcw=
Xref csiph.com comp.lang.java.programmer:28800

Show key headers only | View raw


On 6/20/2014 08:14, Eric Sosman wrote:
> On 6/20/2014 11:06 AM, Knute Johnson wrote:
>> On 6/20/2014 00:25, Robert Klemme wrote:
>>> On 06/20/2014 07:03 AM, Knute Johnson wrote:
>>>> Pattern.compile(Pattern.quote("the string with the ) in it"));
>>>
>>> There are more ways:
>>>
>>> Pattern.compile("the string with the \\) in it");
>>> Pattern.compile("the string with the \\Q)\\E in it");
>>>
>>> Cheers
>>>
>>>      robert
>>
>> Thanks Robert,
>>
>> The problem was actually
>>
>> String str = "(something";
>> Pattern.compile(str);
>>
>> so now it is
>>
>> Pattern.compile(Pattern.quote(str));
>>
>> I hate to make them
>>
>> Pattern.compile(str+"\\Q")
>>
>> (the cognoscenti would have my ...)
>
>      Something seems peculiar: If the cognoscenti who provide the
> search strings want all characters to stand for themselves and
> not to function as regex metacharacters, what's the point of
> using a regex?  Why not use theString.indexOf(str)?  Is there
> more to the use case than we've been told?
>

Well I've been round and round on this, I thought originally that I 
could find all the examples of the search string with one call to 
Matcher.matches() but I can't figure out how to do that.  It may be 
possible but I can't find an example and String.indexOf is case 
sensitive and it is very easy to make Matcher.find() not be which is 
what I want for this application.

As to the cognoscenti, I meant using the + operator to concatenate a 
String but if I can work a Vector in there somewhere I will :-).

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Regex? Knute Johnson <eternal@knutejohnson.com> - 2014-06-19 21:39 -0700
  Re: Regex? Knute Johnson <eternal@knutejohnson.com> - 2014-06-19 22:03 -0700
    Re: Regex? Robert Klemme <shortcutter@googlemail.com> - 2014-06-20 09:25 +0200
      Re: Regex? Knute Johnson <eternal@knutejohnson.com> - 2014-06-20 08:06 -0700
        Re: Regex? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-06-20 11:14 -0400
          Re: Regex? Knute Johnson <eternal@knutejohnson.com> - 2014-06-20 15:46 -0700
            Re: Regex? Roedy Green <see_website@mindprod.com.invalid> - 2014-06-25 08:15 -0700
              Re: Regex? Knute Johnson <eternal@knutejohnson.com> - 2014-06-25 18:10 -0700
                Re: Regex? Knute Johnson <eternal@knutejohnson.com> - 2014-06-30 09:52 -0700
    Re: Regex? Roedy Green <see_website@mindprod.com.invalid> - 2014-06-21 09:49 -0700
  Re: Regex? Roedy Green <see_website@mindprod.com.invalid> - 2014-08-01 02:45 -0700

csiph-web