<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to escape a parenthesis when using rex to create a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154719#M43506</link>
    <description>&lt;P&gt;Thanks! I modified your search command to the following and it worked perfectly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "Session (?\\w+) \\((?\\w+)@"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Oct 2014 16:21:04 GMT</pubDate>
    <dc:creator>Splunkster45</dc:creator>
    <dc:date>2014-10-07T16:21:04Z</dc:date>
    <item>
      <title>How to escape a parenthesis when using rex to create a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154717#M43504</link>
      <description>&lt;P&gt;I have a question about extracting two fields from the below sample text&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Session &amp;lt;number&amp;gt; (&amp;lt;username&amp;gt;@&amp;lt;ipaddress&amp;gt;) started
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to be able to store the variable number and username as a field, but I am running into issues with the '('.   Whenever I run the command, I get an error message saying that I am missing a ')'&lt;/P&gt;

&lt;P&gt;Here is the command that I am using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "Session (?&amp;lt;number&amp;gt;&amp;lt;backslash&amp;gt;w+) ((?&amp;lt;username&amp;gt;&amp;lt;backslash&amp;gt;w+)@"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The number is either a 4 or 5 digit number and the username is always 6 characters. I do not care about the IP address.&lt;/P&gt;

&lt;P&gt;How can I escape the parenthesis? I've done a little bit of searching and found a question that asked about escaping a '(' in a macro, but either that didn't apply or I couldn't follow it.&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2014 16:03:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154717#M43504</guid>
      <dc:creator>Splunkster45</dc:creator>
      <dc:date>2014-10-07T16:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to escape a parenthesis when using rex to create a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154718#M43505</link>
      <description>&lt;P&gt;In PCRE regexes (which Splunk uses), punctuation preceded by a backslash always matches the punctuation, so &lt;CODE&gt;\(&lt;/CODE&gt; matches a &lt;CODE&gt;(&lt;/CODE&gt;.&lt;BR /&gt;
Parens without a backslash form groups as you are using to find your number.  There is a bit of a trick though, because the search language also uses backslashes for escaping.  Therefore I would suggest&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=_raw "Session (?&amp;lt;number&amp;gt;\\w+) (?&amp;lt;username&amp;gt;\\(\\w+)@"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Oct 2014 16:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154718#M43505</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2014-10-07T16:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to escape a parenthesis when using rex to create a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154719#M43506</link>
      <description>&lt;P&gt;Thanks! I modified your search command to the following and it worked perfectly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "Session (?\\w+) \\((?\\w+)@"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Oct 2014 16:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154719#M43506</guid>
      <dc:creator>Splunkster45</dc:creator>
      <dc:date>2014-10-07T16:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to escape a parenthesis when using rex to create a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154720#M43507</link>
      <description>&lt;P&gt;Ah, seems I slightly misunderstood the goal.  In retrospect it should have been obvious.  Glad it's working.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2014 16:31:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-escape-a-parenthesis-when-using-rex-to-create-a-field/m-p/154720#M43507</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2014-10-07T16:31:23Z</dc:date>
    </item>
  </channel>
</rss>

