views:

194

answers:

1

This query concerns Yahoo Pipes only.

I want to search for a series of characters in a feed title, and when I've found it, I want to insert some text. Yahoo Pipe's regex module allows you to search and replace, but I don't want to search and replace, only search and insert. Does anybody know whether this is possible?

+2  A: 

Yes, you can use the regex module to insert some text. Some examples:

Simple insert

If your title is AAACCC and you want to insert BBB to get AAABBBCCC,

replace

AC

with

ABBBC

Simple append

If your title is AAACCC and you want to append BBB to get AAACCCBBB,

replace

$

with

BBB

Insert with capturing groups

For more complicated cases you can use capturing groups. For example suppose your title consists of some letters at the beginning and some digits at the end, like Oct2009. And you want to seperate the letters and numbers with a slash, like Oct - 2009

replace

([a-zA-Z]+)([0-9]+)

with

$1 - $2

Where $1 is the match of the first pair of brackets () and $2 is the match of the second pair of brackets ().

Insert other feed attributes

Suppose your feed items have an attribute author and you want to append by Authorname to the title of your feed,

replace

$

with

by ${author}

For an item with an attribute title=Interesting Text and author=John Doe this will result in title=Interesting Text by John Doe

Arend