I have a set of HTML pages that I'm importing (regularly) into a Drupal site using Feeds and Feeds Tamper.
One of the elements in the feed can take one of two forms:
Birth 1869 Location Merthyr Tydfil, Glamorgan, Wales<a class="gs-pl" href="https://maps.google.com/?t=m&q=51.7479,-3.37779" target="_top" title="Google">G</a>
Marriage Calculated 1894 (i.e. without a Location section).
The feed contains an unlimited number of these elements which will be imported into a multivalued Field Collection attached to a node.
I need to extract part of the Location section (a latitude) or if there is no Location provide a default value of 0.
I'm using the Find Replace Regex plugin to extract the latitude and add a pipe character (to allow me to Explode the results into an array).
My find regex currently looks like:
which either identifies the latitude or returns the full string if there is no Location element.
My replace regex looks like:
\1| which works fine for the case where the Location element exists.
However, I can't see how to replace any empty string returned (i.e. when the capturing group is emtpy) with a figure 0.
Is this possible using the Find Replace Regex plugin, on its own or in combinations of other tampers as well? I wondered if I could process the original element to add a Location element with the values required as a default if it was missing but that still involves a conditional replacement so it's essentially the same problem.
I can't set insert missing Location elements in the HTML before the import, and setting the default value in the String Collection doesn't work because of the way field collections are imported (basically the method I'm using puts the data in the wrong field collection item if there are any empty fields)