substring before or after in wordpress automatic plugin

How to extract a substring before or after a specific string in WordPress Automatic Plugin

WordPress Automatic Plugin can scrape the web and grab the desired parts of the content using its Feeds or Multi-page scraper modules but there is a case where the part we want to extract is a simply a part of the picked text

for example in this URL http://ufcstats.com/fight-details/96704d7ba3a452d9 we want the extract the first part “75” only and not the whole part “75 of 128”

If we use the visual selector, the whole text only can be selected

Here is how to only grab the first part of the selected text from the visual selector

  1. Pick the whole part using the visual selector

  2. copy the returned xpath to a text editor so we can modify

    In my case, the XPath was

    /html/body/section/div/div/section[2]/table/tbody/tr/td[3]/p[1]

  3. Modify the XPath to besubstring-before({copied_Xpath}, ' of') so the final Xpath is substring-before(/html/body/section/div/div/section[2]/table/tbody/tr/td[3]/p[1], ' of')
  4. paste it instead of the one we copied before

This should return the value before of so the final value will be 75 and to get the part after the of text, we can similarly use the substring-after XPath

substring-after({copied_Xpath}, ' of')

 

Leave a Reply

Your email address will not be published. Required fields are marked *