Splunk Search

Field Extraction from html tags

Nadhiyaa
Path Finder

  • align="left"> Accepted

    <td align="right" class="mailViewRowReadEven"> 64399
    

    <td align="right" class="mailViewRowReadEven">
    

    56.32%

I want to extract the field Accepted=64399

Tags (1)
0 Karma

niketn
Legend

@Nadhiyaa, you will need to post the <html> code on Splunk Answers question using the code button i.e. with 101010 or Ctrl+K as the shortcut key after you have selected all html code, to ensure that it does not escape.

Based on bare minimal html required as per your question you can try the following rex command. Please try the following run anywhere search to test the same.

| makeresults
| eval _raw=" Accepted  
<td align=\"right\" class=\"mailViewRowReadEven\"> 64399
    </td>"
| rex "\sAccepted\s+\<td align=\"right\" class=\"mailViewRowReadEven\"\>\s(?<Accepted>\d+)\s+\<\/td\>"

Above regular expression uses \d+ to get Accepted numbers as per the sample data provided.
While I have not tested this, but check out the html2text app from Splunkbase as well.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Nadhiyaa
Path Finder

@niketnilay

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...