<?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 do I write a regular expression to extract 2 fields from my sample data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284454#M86009</link>
    <description>&lt;P&gt;you could try those two:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "RESPONSE_CODE:(?P&amp;lt;RespCode&amp;gt;\d+)"

rex field=_raw "errorCode\":\"(?P&amp;lt;ErrorCode&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: escaped quotes and used + thanks to richgalloway&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2016 15:47:15 GMT</pubDate>
    <dc:creator>PPape</dc:creator>
    <dc:date>2016-09-14T15:47:15Z</dc:date>
    <item>
      <title>How do I write a regular expression to extract 2 fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284453#M86008</link>
      <description>&lt;P&gt;So I have a search that will check if two variables equal a specific number, and then I get the count of these instances. I am having trouble regexing the numbers I needed to create the variables.&lt;/P&gt;

&lt;P&gt;index=nitro_prod_ecomm errorCode |rex &lt;STRONG&gt;(This grabs the Response Code)&lt;/STRONG&gt; | rex  &lt;STRONG&gt;(This grabs Error Code)&lt;/STRONG&gt; | where RespCode = 400 AND ErrorCode = 1001 | table count&lt;/P&gt;

&lt;P&gt;REQUEST_BODY:&lt;BR /&gt;
{profileId:0156",deviceId:D893-4324234234C"}&lt;BR /&gt;
RESPONSE_CODE:&lt;STRONG&gt;400&lt;/STRONG&gt;&lt;BR /&gt;
RESPONSE_TIME:2&lt;BR /&gt;
RESPONSE_HEADERS:&lt;BR /&gt;
Date:Wed, 14 Sep 2016 15:10:17 GMT;&lt;BR /&gt;
X-Powered-By:Servlet/3.0;&lt;BR /&gt;
correlation-id:NAID-iOS-E6B4F6817.94320;&lt;BR /&gt;
channel:IOS;&lt;BR /&gt;
Content-Type:application/json;&lt;BR /&gt;
Transfer-Encoding:chunked;&lt;BR /&gt;
Connection:Close;&lt;BR /&gt;
RESPONSE_BODY:&lt;BR /&gt;
{"errors":[{"errorCode":"&lt;STRONG&gt;1001&lt;/STRONG&gt;","message":""}]}&lt;/P&gt;

&lt;P&gt;_WS_HAPRT_WLMVERSION:-1;&lt;BR /&gt;
RESPONSE_CODE:&lt;STRONG&gt;500&lt;/STRONG&gt;&lt;BR /&gt;
RESPONSE_TIME:11&lt;BR /&gt;
RESPONSE_HEADERS:&lt;BR /&gt;
X-Powered-By:Servlet/3.0;&lt;BR /&gt;
correlation-id:TID-14743243247;&lt;BR /&gt;
Content-Type:application/json;&lt;BR /&gt;
Transfer-Encoding:chunked;&lt;BR /&gt;
Connection:Close;&lt;BR /&gt;
Date:Wed, 14 Sep 2016 15:33:13 GMT;&lt;BR /&gt;
RESPONSE_BODY:&lt;BR /&gt;
{"errors":[{"errorCode":"&lt;STRONG&gt;1010&lt;/STRONG&gt;","message":""}]}&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:01:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284453#M86008</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2020-09-29T11:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a regular expression to extract 2 fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284454#M86009</link>
      <description>&lt;P&gt;you could try those two:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "RESPONSE_CODE:(?P&amp;lt;RespCode&amp;gt;\d+)"

rex field=_raw "errorCode\":\"(?P&amp;lt;ErrorCode&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: escaped quotes and used + thanks to richgalloway&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 15:47:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284454#M86009</guid>
      <dc:creator>PPape</dc:creator>
      <dc:date>2016-09-14T15:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a regular expression to extract 2 fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284455#M86010</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nitro_prod_ecomm errorCode |rex "RESPONSE_CODE:(?&amp;lt;RespCode&amp;gt;\d+)" | rex "\"errorCode\":\"(?&amp;lt;ErrorCode&amp;gt;\d+)\"" | where RespCode = 400 AND ErrorCode = 1001 | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2016 15:48:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284455#M86010</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-14T15:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a regular expression to extract 2 fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284456#M86011</link>
      <description>&lt;P&gt;Try these two regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "errorCode\"\:\"(?&amp;lt;err_code&amp;gt;\d+)\"" | rex "RESPONSE_CODE\:(?&amp;lt;resp_code&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2016 15:49:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284456#M86011</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-14T15:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a regular expression to extract 2 fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284457#M86012</link>
      <description>&lt;P&gt;The quotes with the regex will have to be escaped.&lt;BR /&gt;
I prefer to use &lt;CODE&gt;\d+&lt;/CODE&gt; to avoid assumptions about the length of a number.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 15:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-regular-expression-to-extract-2-fields-from-my/m-p/284457#M86012</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-09-14T15:51:22Z</dc:date>
    </item>
  </channel>
</rss>

