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


Groups > comp.lang.java.help > #1966

Re: Regexp help

From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
Newsgroups comp.lang.java.help
Subject Re: Regexp help
References <3e0aa0ea-bdb5-4cd5-bdae-4fcd31c70a7f@googlegroups.com> <jVfUr.51896$ls7.32117@newsfe11.iad> <e8fd1c92-6f54-48ee-8cc9-ec5a10d03ce5@googlegroups.com>
Message-ID <HcwUr.685$CE7.526@newsfe12.iad> (permalink)
Date 2012-08-08 09:11 -0700

Show all headers | View raw


On 8/7/12 10:14 PM, mike wrote:
> On Tuesday, August 7, 2012 11:38:21 PM UTC+2, Daniel Pitts wrote:
>> On 8/7/12 7:03 AM, mike wrote:
>>
>>> Hi,
>>
>>>
>>
>>> I have the following:
>>
>>>
>>
>>> Input 1: Needs Merge "." [(automatic) to \main\2 from \main\rel1\2 (base also \main\2)]
>>
>>>
>>
>>> Input 2: Needs Merge "./update" [to /main/4 from /main/bugfix/1 base /main/2]
>>
>>>
>>
>>> I have the following regexp:
>>
>>>
>>
>>> Needs\s+Merge\s+\"(.*)\"\s+\[(\(automatic\)\s)?to\s+(.*)\s+from\s+(.*)\s+\(?base\s{1}(also\s{1})?(.*)\]
>>
>>>
>>
>>> The last grouping (6) is:
>>
>>>
>>
>>> Input 1: \main\2)
>>
>>>
>>
>>> Input 2: /main/2
>>
>>>
>>
>>> How can I avoid get the parenthesis to be included in group(6) for input 1?
>>
>>
>>
>> How about adding a \) after your group 6?
>
> I tried it and it works for input #1 but not for #2.
>>
>>
>>
>> or replacing your .* with [^)]*
>
> I tried it and it works for input #2 but not for input #1.
>
>
> What I need is a regexp that works for both input.
>>
>>
>>
>> Either of those should solve the problem. Each has different trade-offs
>>
>> depending on your typical input.
>

Well, you could also add a \)?\].  Or, you could have two regexs.  Or 
you could combine the regexs.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Regexp help mike <mikaelpetterson@hotmail.com> - 2012-08-07 07:03 -0700
  Re: Regexp help Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-08-07 14:38 -0700
    Re: Regexp help mike <mikaelpetterson@hotmail.com> - 2012-08-07 22:14 -0700
      Re: Regexp help Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-08-08 09:11 -0700
        Re: Regexp help markspace <-@.> - 2012-08-08 10:16 -0700
          Re: Regexp help Gene Wirchenko <genew@ocis.net> - 2012-08-08 12:13 -0700
            Re: Regexp help markspace <-@.> - 2012-08-08 14:15 -0700
              Re: Regexp help Gene Wirchenko <genew@ocis.net> - 2012-08-08 18:43 -0700

csiph-web