Author Topic: () grouping in Brief regular expressions broken?  (Read 3866 times)

StephenW

  • Senior Community Member
  • Posts: 197
  • Hero Points: 21
() grouping in Brief regular expressions broken?
« on: April 30, 2007, 10:18:24 pm »
I have been having problems getting grouping (sub-expressions) to work in Brief regular expressions in SE 2007, and today I came across a test case that shows it nicely.  This is some of the data I am searching (a log file):

L2 P01 PT27  01 - C1
L3 P01 PT00  01 - 61
L3 P01 PT00  01 - 61
L2 P01 PT27  01 - C1
L2 P01 PT27  01 - C1
L3 P01 PT00  01 - 61
L2 P01 PT27  01 - C1
L3 P01 PT00  01 - 61
L2 P01 PT27  01 - C1
L3 P01 PT00  01 - 61
L3 P01 PT00  01 - 61
L2 P01 PT27  01 - C1
L2 P01 PT27  01 - C1
L3 P01 PT00  01 - 61
L2 P01 PT27  01 - C1
L3 P01 PT00  01 - 61

and here is the regular expression that does not work:

(L3 P01 PT00  01 - 61)

When I put these into the Regex evaluator tool, and changed the () grouping to {}:

{L3 P01 PT00  01 - 61}

I get matches as I would have expected.  I am fairly sure this used to work in some earlier version of SE, but it has been a while since I needed to use non-tagging grouping.  I am beginning to think that using () for grouping is broken, as what I am doing seems proper according to the documentation.  When I try the same regular expressions in SlickEdit mode, both of them work.

jbhurst

  • Senior Community Member
  • Posts: 405
  • Hero Points: 33
Re: () grouping in Brief regular expressions broken?
« Reply #1 on: May 01, 2007, 12:44:38 am »
Hi,

My reading of the documentation is that with Brief Regular Expressions, you can use braces {} for tagged subexpressions, and backslashed parentheses \( \) for non-tagged subexpressions.

I tend to use UNIX style regexes myself, so I can't recall the behavior of Brief regexes in earlier versions.

Hope this helps,

John Hurst
Wellington, New Zealand

StephenW

  • Senior Community Member
  • Posts: 197
  • Hero Points: 21
Re: () grouping in Brief regular expressions broken?
« Reply #2 on: May 01, 2007, 03:44:53 am »
That fixes it, thank you.  Looks like I have been writing too many macros recently - I always use SlickEdit regex syntax there, as there used to be no choice in macros.  Brief itself never had the \(\) grouping (that was added in SlickEdit to keep the different regex formats at the same level of capability), so I have not used it much and managed to get it wrong.