<?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: Regex Working in Regex Tester But Not in Splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275637#M83142</link>
    <description>&lt;P&gt;Hi Chris,&lt;/P&gt;

&lt;P&gt;I think I've found where your problem is. It's just the matter of placing the double quote character. Your rex was like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | rex field="detail.authority" ""\"loggedInAt":\"(?&amp;lt;LoggedIn&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried in my local environment using your sample data and it clearly was not working. So, I altered the rex into something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | rex field="detail.authority" "\"loggedInAt\":\"(?&amp;lt;LoggedIn&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The things I've tweaked are:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Remove the first double quote&lt;/LI&gt;
&lt;LI&gt;Add backslash to the double quote after loggedInAt&lt;/LI&gt;
&lt;LI&gt;Add backslash to the last double quote and add another double quote at the end&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;This should solve your problem.&lt;/P&gt;

&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2015 09:58:03 GMT</pubDate>
    <dc:creator>vincenteous</dc:creator>
    <dc:date>2015-10-19T09:58:03Z</dc:date>
    <item>
      <title>Regex Working in Regex Tester But Not in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275635#M83140</link>
      <description>&lt;P&gt;Hi, I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I've put together this regex which works perfectly in Regex101:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\"loggedInAt":\"(?&amp;lt;LoggedIn&amp;gt;[^\"]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This correctly extracts the 'loggedInAt' value from the raw data as shown below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"uri":"/auth/oid/4a1f00001b00002eb5","loggedInAt":"2015-10-18T18:30:34.976Z","credentials":{"gatewayId":"0000000"},"accounts":{"iht":{"link":"/iht/AA112456","nino":"AA111111A"},"sa":{"link":"/individual/12345678","ur":12345678"},"taxs":{"link":"/taxs/12345678","ur":"12345678"}},"lastUpdated":"2015-10-18T18:30:34.976Z","levelOfAssurance":"2","confidenceLevel":500}.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I then use this line in my Splunk query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field="detail.authority" ""\"loggedInAt":\"(?&amp;lt;LoggedIn&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem I have is that when I come to add "LoggedIn" to my table the relevant information is not being extracted and I'm nit sure why.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone could look a this please and let me know where I've gone wrong.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 07:39:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275635#M83140</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-19T07:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Working in Regex Tester But Not in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275636#M83141</link>
      <description>&lt;P&gt;Splunk has some issues with double quotes inside double quotes, at least thats what I've experienced before. Therefore I always try to avoid using them in rexes. Try this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "loggedInAt\W\:\W(?&amp;lt;VALUE&amp;gt;.*?)\W,"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Oct 2015 09:55:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275636#M83141</guid>
      <dc:creator>dkoops</dc:creator>
      <dc:date>2015-10-19T09:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Working in Regex Tester But Not in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275637#M83142</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;

&lt;P&gt;I think I've found where your problem is. It's just the matter of placing the double quote character. Your rex was like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | rex field="detail.authority" ""\"loggedInAt":\"(?&amp;lt;LoggedIn&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried in my local environment using your sample data and it clearly was not working. So, I altered the rex into something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | rex field="detail.authority" "\"loggedInAt\":\"(?&amp;lt;LoggedIn&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The things I've tweaked are:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Remove the first double quote&lt;/LI&gt;
&lt;LI&gt;Add backslash to the double quote after loggedInAt&lt;/LI&gt;
&lt;LI&gt;Add backslash to the last double quote and add another double quote at the end&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;This should solve your problem.&lt;/P&gt;

&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 09:58:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275637#M83142</guid>
      <dc:creator>vincenteous</dc:creator>
      <dc:date>2015-10-19T09:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Working in Regex Tester But Not in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275638#M83143</link>
      <description>&lt;P&gt;Hi @vincenteous, thank you very much for this it works a treat.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 10:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Working-in-Regex-Tester-But-Not-in-Splunk/m-p/275638#M83143</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-19T10:19:30Z</dc:date>
    </item>
  </channel>
</rss>

