<?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 create a regular expression for a field in a log file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243306#M72427</link>
    <description>&lt;P&gt;The one given by @sundareshr should work fine if office code has &lt;CODE&gt;\w&lt;/CODE&gt; worth of data, however if there are more than &lt;CODE&gt;\w&lt;/CODE&gt; type of data that can be part of officeCode then you can give this a try as well as &lt;CODE&gt;\w only covers [a-zA-Z0-9_]&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "OfficeCode\&amp;gt;(?&amp;lt;OfficeCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;" | table OfficeCode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Nov 2016 18:43:27 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-11-21T18:43:27Z</dc:date>
    <item>
      <title>How to create a regular expression for a field in a log file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243304#M72425</link>
      <description>&lt;P&gt;Hi, first of all thanks for help me.&lt;/P&gt;

&lt;P&gt;I have this log file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-11-21T16:29:25.690+0100 INFO    2867 com.l7tech.log.custom.csm: -4: SplunkService=LIVEpolicy_csmws_poas
... 20 lines omitted ...
                  &amp;lt;![CDATA[
                     &amp;lt;CategoryAvailabilityRequest&amp;gt;
    &amp;lt;SessionInfo&amp;gt;
        &amp;lt;SessionID&amp;gt;value&amp;lt;/SessionID&amp;gt;
        &amp;lt;Profile&amp;gt;A&amp;lt;/Profile&amp;gt;
        &amp;lt;Language&amp;gt;DEU&amp;lt;/Language&amp;gt;
        &amp;lt;Version&amp;gt;1&amp;lt;/Version&amp;gt;
    &amp;lt;/SessionInfo&amp;gt;
    &amp;lt;BookingContext&amp;gt;
        &amp;lt;AgencyID&amp;gt;value&amp;lt;/AgencyID&amp;gt;
        &amp;lt;BookingContactName&amp;gt;XML Test&amp;lt;/BookingContactName&amp;gt;
        &amp;lt;MarketCode&amp;gt;value&amp;lt;/MarketCode&amp;gt;
        &amp;lt;BookingCurrencyCode&amp;gt;value&amp;lt;/BookingCurrencyCode&amp;gt;
        &amp;lt;LanguageCode&amp;gt;value&amp;lt;/LanguageCode&amp;gt;
        &amp;lt;OfficeCode&amp;gt;DEU&amp;lt;/OfficeCode&amp;gt;
    &amp;lt;/BookingContext&amp;gt;
    &amp;lt;CruiseComponent&amp;gt;
        &amp;lt;ComponentID&amp;gt;value&amp;lt;/ComponentID&amp;gt;
        &amp;lt;PromotionCode&amp;gt;didu20198212&amp;lt;/PromotionCode&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to create the field &lt;STRONG&gt;OfficeCode&lt;/STRONG&gt; then take the value to create a dashboard.&lt;/P&gt;

&lt;P&gt;Splunk in automatic way do not recognize this field, could you help me to create a regular expression?&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Massimiliano&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 16:03:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243304#M72425</guid>
      <dc:creator>mderosa</dc:creator>
      <dc:date>2016-11-21T16:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regular expression for a field in a log file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243305#M72426</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "OfficeCode\&amp;gt;(?&amp;lt;office_code&amp;gt;\w+)\&amp;lt;" |...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Nov 2016 17:14:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243305#M72426</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-21T17:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regular expression for a field in a log file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243306#M72427</link>
      <description>&lt;P&gt;The one given by @sundareshr should work fine if office code has &lt;CODE&gt;\w&lt;/CODE&gt; worth of data, however if there are more than &lt;CODE&gt;\w&lt;/CODE&gt; type of data that can be part of officeCode then you can give this a try as well as &lt;CODE&gt;\w only covers [a-zA-Z0-9_]&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "OfficeCode\&amp;gt;(?&amp;lt;OfficeCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;" | table OfficeCode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Nov 2016 18:43:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243306#M72427</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-21T18:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regular expression for a field in a log file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243307#M72428</link>
      <description>&lt;P&gt;Thank you both the expression works well!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 08:38:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regular-expression-for-a-field-in-a-log-file/m-p/243307#M72428</guid>
      <dc:creator>mderosa</dc:creator>
      <dc:date>2016-11-22T08:38:34Z</dc:date>
    </item>
  </channel>
</rss>

