<?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 Boolean in Regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90756#M23308</link>
    <description>&lt;P&gt;Im trying to solve a problem with my regex.&lt;BR /&gt;
Im extracting the username from an XML transaction.&lt;BR /&gt;
Sometimes the username comes like this (Byt the way, I think I dont know how to post XML code on the SplunkBase because it gets processed by the editor, so Im omitin some "&amp;gt;" and "&amp;lt;" to get it out).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;login&amp;gt;user1@gmail.com&amp;lt;/login&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can get it with this Regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)&amp;lt;login&amp;gt;(?P&amp;lt;CustomerName&amp;gt;[^&amp;lt;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And sometimes like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;login xmlns=""&amp;gt;user2@gmail.com&amp;lt;/login&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can get it with this Regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i) xmlns=""&amp;gt;(?P&amp;lt;CustomerName&amp;gt;[^&amp;lt;]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Im trying to get a Regex that satisfy both cases,, I was thinking about a boolean, like OR (||) between the two REGEX, but it didnt work.&lt;BR /&gt;
Im new to this and I dont know how to use it.&lt;BR /&gt;
Thanks!!&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2011 13:27:56 GMT</pubDate>
    <dc:creator>DotTest37</dc:creator>
    <dc:date>2011-04-28T13:27:56Z</dc:date>
    <item>
      <title>Boolean in Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90756#M23308</link>
      <description>&lt;P&gt;Im trying to solve a problem with my regex.&lt;BR /&gt;
Im extracting the username from an XML transaction.&lt;BR /&gt;
Sometimes the username comes like this (Byt the way, I think I dont know how to post XML code on the SplunkBase because it gets processed by the editor, so Im omitin some "&amp;gt;" and "&amp;lt;" to get it out).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;login&amp;gt;user1@gmail.com&amp;lt;/login&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can get it with this Regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)&amp;lt;login&amp;gt;(?P&amp;lt;CustomerName&amp;gt;[^&amp;lt;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And sometimes like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;login xmlns=""&amp;gt;user2@gmail.com&amp;lt;/login&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can get it with this Regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i) xmlns=""&amp;gt;(?P&amp;lt;CustomerName&amp;gt;[^&amp;lt;]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Im trying to get a Regex that satisfy both cases,, I was thinking about a boolean, like OR (||) between the two REGEX, but it didnt work.&lt;BR /&gt;
Im new to this and I dont know how to use it.&lt;BR /&gt;
Thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2011 13:27:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90756#M23308</guid>
      <dc:creator>DotTest37</dc:creator>
      <dc:date>2011-04-28T13:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Boolean in Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90757#M23309</link>
      <description>&lt;P&gt;How about&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;login[^&amp;gt;]*&amp;gt;(?P&amp;lt;CustomerName&amp;gt;[^&amp;lt;]+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2011 14:30:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90757#M23309</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-04-28T14:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Boolean in Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90758#M23310</link>
      <description>&lt;P&gt;You can use a single &lt;CODE&gt;|&lt;/CODE&gt; symbol as an OR in regex, but you don't really need to in this case. Something like the following should work, where you simply tell it to consume any optional characters before the &lt;CODE&gt;&amp;lt;login&amp;gt;&lt;/CODE&gt; tag's closing bracket.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)&amp;lt;login [^&amp;gt;]*&amp;gt;(?&amp;lt;PCustomerName&amp;gt;[^&amp;lt;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
If you really want an OR condition, you use a vertical bar (pipe) symbol, like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(&amp;lt;login&amp;gt;)|(&amp;lt;login xmlns=""&amp;gt;)(?&amp;lt;PCustomerName&amp;gt;[^&amp;lt;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
For a good reference take a look at &lt;A href="http://www.regular-expressions.info/"&gt;http://www.regular-expressions.info/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also, check out &lt;A href="http://kodos.sourceforge.net/"&gt;Kodos&lt;/A&gt; or &lt;A href="http://www.regexbuddy.com/"&gt;Regex Buddy&lt;/A&gt; if you need a good way to test.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2011 14:33:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90758#M23310</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2011-04-28T14:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Boolean in Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90759#M23311</link>
      <description>&lt;P&gt;I tested your rewritten RegEx and they worked perfect. Im new to this and try to learn. &lt;BR /&gt;
How do you actually use a Boolean | with the Splunk variables? an example will give me a quickstart.&lt;BR /&gt;
Thanks guys.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2011 18:51:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90759#M23311</guid>
      <dc:creator>DotTest37</dc:creator>
      <dc:date>2011-04-28T18:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Boolean in Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90760#M23312</link>
      <description>&lt;P&gt;m new to this and try to learn. How do you actually use a Boolean | with the Splunk variables? an example will give me a quickstart. Thanks guys.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2011 00:13:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Boolean-in-Regex/m-p/90760#M23312</guid>
      <dc:creator>DotTest37</dc:creator>
      <dc:date>2011-04-29T00:13:15Z</dc:date>
    </item>
  </channel>
</rss>

