<?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 use Rex Command in Python/C# SDK in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Rex-Command-in-Python-C-SDK/m-p/193158#M55563</link>
    <description>&lt;P&gt;In Python, you could use triple quotes to surround the string instead of the single quotes like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search_query = """sourcetype=csv| search 48,2 | rex field=_raw "(d+,){0}(?&amp;lt;tableid&amp;gt;d+)" | rex field=_raw "(d+,){101}(?&amp;lt;table_value&amp;gt;d+)" | stats list(TableID) as Table, list(Table_value) as Value"""
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Jan 2014 16:31:53 GMT</pubDate>
    <dc:creator>jsie_splunk</dc:creator>
    <dc:date>2014-01-02T16:31:53Z</dc:date>
    <item>
      <title>How to use Rex Command in Python/C# SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Rex-Command-in-Python-C-SDK/m-p/193157#M55562</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a CLI query which works perfectly on Splunk Web terminal and the same thing I want to replicate it using SDK&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`sourcetype=csv| search 48,2 | rex field=_raw "(\d+,){0}(?&amp;lt;TableID&amp;gt;\d+)" | rex field=_raw "(\d+,){101}(?&amp;lt;Table_value&amp;gt;\d+)" | stats list(TableID) as Table, list(Table_value) as Value`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now Problem is when I put above search query as &lt;STRONG&gt;&lt;CODE&gt;search_query = "sourcetype=csv| search 48,2 | rex field=_raw "(\d+,){0}(?&amp;lt;TableID&amp;gt;\d+)" | rex field=_raw "(\d+,){101}(?&amp;lt;Table_value&amp;gt;\d+)" | stats list(TableID) as Table, list(Table_value) as Value"&lt;/CODE&gt;&lt;/STRONG&gt; then due to " at the start and " before the "(\d+,){101} counts it as a sepreate string to which I used the following mechanism&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`rex1 = "(\d+,){0}(?&amp;lt;TableID&amp;gt;\d+)"
rex2 = "(\d+,){101}(?&amp;lt;Table_value&amp;gt;\d+)"
query = "search sourcetype=csv| search 48,2 | rex field=_raw" + rex1 + "|rex field=_raw " + "|stats list(TableID) as Table, list(Table_value) as Value"`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But still it is not working. I get 400 - Bad Request Error. Same thing I even tried in C# SDK, there even &lt;CODE&gt;"\"&lt;/CODE&gt; is a escape sequence, to resolve it I used @ but even in C# the error remained the same.&lt;/P&gt;

&lt;P&gt;Kindly help me to resolve it, because there is no use of SDK as we are limited to not been able to use Rex and various other commands where &lt;CODE&gt;"\"&lt;/CODE&gt; or any other escape sequence is used.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2014 09:11:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Rex-Command-in-Python-C-SDK/m-p/193157#M55562</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2014-01-02T09:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rex Command in Python/C# SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Rex-Command-in-Python-C-SDK/m-p/193158#M55563</link>
      <description>&lt;P&gt;In Python, you could use triple quotes to surround the string instead of the single quotes like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search_query = """sourcetype=csv| search 48,2 | rex field=_raw "(d+,){0}(?&amp;lt;tableid&amp;gt;d+)" | rex field=_raw "(d+,){101}(?&amp;lt;table_value&amp;gt;d+)" | stats list(TableID) as Table, list(Table_value) as Value"""
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jan 2014 16:31:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Rex-Command-in-Python-C-SDK/m-p/193158#M55563</guid>
      <dc:creator>jsie_splunk</dc:creator>
      <dc:date>2014-01-02T16:31:53Z</dc:date>
    </item>
  </channel>
</rss>

