Sign In with your Yahoo! ID or Join Now

Thank you for using Yahoo Pipes! To help focus our efforts on core Yahoo product experiences, users will no longer be able to create new Pipes starting August 30th 2015. The service will be put in read-only mode until we will discontinue Yahoo Pipes on September 30th 2015. You can find more details here.

Module Reference: String Modules

These modules help manipulate and combine strings.

Module Output: text

String Builder Module

This module is useful when you need to build a string from multiple substrings, some coded into the Pipe, other parts supplied when the Pipe is run.

String Concatenation lets you define one or more substrings. To get more substrings you simply click the modules plus button. To delete a substring just click the x button to its left.

Example: Run this Pipe | View Source

The Yahoo! Search module lets you enter a Site restriction for the search. This is a URL, but it can be irritating to always have to enter the "http://" part of the URL. Using the String Concatenation module, this example builds the URL from two substrings: the first is "http://" coded directly into the module, the second is the rest of the URL, provided via a wired-in Text Input module.

The output from String Builder is wired into the "Site restriction" section of the Yahoo! Search module, but not directly. String Builder outputs a text value, but the Site restriction section can only accept a url value. We get around this problem by connecting String Builder to a URL Builder module, then wiring its output into Yahoo! Search.

Module Output: text

String Regex Module

This module works much like the Regex module, but whereas that module operates on each item in a feed, the String Regex module works on a single input string.

Regex is an abbreviation for Regular Expression a powerful pattern-matching notation used to modify text. It's described in more detail in the description of the Regex module.

Example: Run this Pipe | View Source

This example transforms a simple web site name, like "cnn", or "reuters", or "abcnews", into a valid URL. So "cnn" becomes "".

We use a Text Input module to get the original string (such as "cnn"), then pass this into the String Regex module. Here we write a regular expression rule: "(.+)". The dot (".") is regex short-hand for "match any character". The plus sign ("+") means "match one or more of the preceding character". Combined, ".+" means "match one or more of any character". In practice, this means that the entire input string will be matched.

The second half of the regex rule defines what will happen to whatever part of the input string we matched. Since the entire string is matched, the entire string will be redefined. The second half of the regex is "http://$". The "http://" at the start, and ".com" at the end are simply literal strings - they mean exactly what they say. But what about the $1?

You may have wondered what the parenthesis were for in the first half of our regex: "(.+)". Any part of a regex surrounded by parenthesis is stored in a numbered variable. The first matching parenthesis are $1, the second are $2, and so on, from left to right in the string. If our input string was "reuters", then $1 contains "reuters", and this means our string becomes "".

Though not directly related to our explanation of the String Regex module, it's useful to look at what we do with the resulting string after it's been transformed. Though the string looks like a URL, it's in fact of type text. We want to use this string as input into the Site restriction field of a Yahoo! Search module. Unfortunately, that field can only receive input of type URL. What do we do?

Fortunately, the URL Builder module can accept a Base URL of type text. So we wire the output from String Regex into a URL Builder module. We leave the Path elements and Query parameters blank. URL Builder outputs a URL type, which can then be wired into Yahoo! Search's Site restriction field.

The URL Builder module is handy whenever you need to coerce a text string into a URL data type.

Module Input: datetime, location, number, text, url | Module Output: text

String Replace Module

The String Replace module provides a general string search-and-replace function for your Pipes. You provide the module with the text string to search for, and what to replace it with. Multiple search-and-replace pairs can be added (using the plus button). You can specify to replace all occurences of the search string, or just the first or last occurrence.

Example: Run this Pipe | View Source

This example uses String Replace to filter the user's input into a Yahoo! Search. We don't want the user to search for potentially harmful information, so we replace dangerous terms like explosive, bomb, and gun with benign alternatives like penguin, rabbit, and turtle.

Module Input: datetime, location, number, text, url | Module Output: items

String Tokenizer Module

This module splits a string into an array of strings. A delimiter string (often just a single character) tells the module where to split the input string. The delimiter string doesn't appear in the output list.

If this string:

		Once//twice//thrice//no more

is input into String Tokenizer, and the delimiter is set to "//", it produces four items:

Example: Run this Pipe | View Source

This example connects a text user input module to string tokenizer to create an array of search terms. The term delimiter is a comma. These terms are passed into a Loop module containing a Yahoo! Search sub-module.

The Search sub-module is site restricted to Wikipedia, and the loop is configured to only output the first result for each search.

If you enter the string "frog,vanilla,pulp fiction" into the text input box, the resulting feed will have three items:

Module Input: datetime, location, number, text, url | Module Output: items

Sub String Module

This module lets you get just a portion of a string. You enter two numbers to tell the module the starting character position and the length of the resulting substring.

If your input string is "ABCDEFG", then a From value of 2 and length of 4 gives you a resulting string of "CDEF". Notice that the first character in the original string is 0, not 1.

If you enter too long a length, the module just returns a substring to the end of the input string, so if you enter a From of 3 and a length of 100, you'll get a result of "DEFG".

Example: Run this Pipe | View Source

Sometimes it's easier to pick from a numbered list then to enter a value explicitly. And sometimes you just want to limit input options to a pre-selected array of options.

In this example, we create a pseudo-array using the String Concatenate module. We enter three search terms into String Concatenate, and pad them with blank spaces so each string is exactly 12 charactes long:

			"shakepeare  "
			"einstein    "
			"roman empire"

We pipe the output of this module into our Sub String module. Next, we use a Number Input module to enter our array index. This gets piped through a couple of Simple Math modules to calculate the offset into our pseudo-array (which is really just a big string). This offset value is then wired into the From value of our Sub String module. Our length value is always 12, because we've made sure to pad each substring out with enough blanks. Finally, the output from Sub String is wired into a Yahoo! Search module.

Module Input: datetime, location, number, text, url | Module Output: items

Term Extractor Module

This module analyzes text piped into it, and tries to find the most significant few words within it. The Term Extractor module can output either a single text string containing all the significant words, or a list of word groupings.

If you opt for a list of results, each resulting item is a set of words that Term Extractor thinks are related. For example, if you input "camels are animals not indigenous to Southern California", Term Extractor returns three items: "camels", "southern california", and "animals". If you chose instead to return output as a single item, it would have simpley been "camels southern california animals".

The Term Extractor module replaces the now-deprecated Content Analysis module.

Example: Run this Pipe | View Source

The Term Extractor is often used as a sub-module within a Loop module. In this example we use Term Extractor to evaluate each item from an input news feed.

The item.description field is fed into Term Extractor by setting the "For each" list box in the Loop module. We select the Loop option to emit all results.

We send this output into another Loop module with a Yahoo! Search sub-module. We have Yahoo! Search look for terms defined in the input list. The end results are those items that matched the words found from Term Extractor.

Module Input: datetime, location, number, text, url | Module Output: text

Translate Module

Translate takes a text item -- such as an element from a feed -- and translates it from one language to another. This module is often used within the Loop module as a sub-module to translate an element of a feed.

Translate can also be used to translate user input. You can wire a Text Input module into Translate to convert, for example, German input into English text before passing the text into a Yahoo! Search module.

You can translate between various languages, including English, French, Japanese, Dutch, German, Greek, Italian, Portuguese, Chinese, Russian, Korean, and Spanish.

This model replaces the now-deprecated BabelFish module.

Example: Run this Pipe | View Source

This example uses Yahoo! Search to find information on Napoleon in the French-language version of Le Monde. Using Translate as a sub-module to Loop, we translate the item.description element into English. The Loop module assigns the translated text back to item.description.

Note that only the description element is translated. To translate other elements, you can add additional Loop/Translate modules.

Module Input: datetime, location, number, text, url | Module Output: items

Yahoo! Shortcuts Module

This module takes a text string as its input, evaluating the words in the text to help categorize it. It can create categories that include PLACE, PERSON, IDENTIFIER (such as phone numbers or email addresses) and CONCEPT. Each of these sub-items contains additional information, such as prediction probability, the start and end character locations where the item was found, and the section of the text that matched the category.

For example, if you feed this text into Yahoo! Shortcuts:

George Washington and his men spent a cold winter in Valley Forge.

Yahoo! Shortcuts will return three items: "cold winter", "George Washington", and "Valley Forge".

"Cold winter" is categorized as a CONCEPT. "George Washington", as expected, is categorized as a PERSON, with a probability of 0.999738. And "Valley Forge" is categorized as a PLACE. The "Valley Forge" category contains additional information, including detailed geocode data (including state, country, latitude, longitude, and zip code).

Yahoo! Shortcuts is most often used as a sub-module inside a Loop module. There it analyzes some element (often the description field) of the input feed.

Example: Run this Pipe | View Source

This example reads the Internet Movie Database's "Born on this Date" feed. This feed is passed into a Loop module with a Yahoo! Shortcuts sub-module. Each item's description element is analyzed by Yahoo! Shortcuts.

Each feed description follows the same pattern: "In [YEAR], [PERSON] was born on this date in [PLACE]." The Shortcuts module creates a PLACE item in the output feed. We then pass the data through a Filter module, which compares the PLACE.title field to a user-provided (via a Text Input module) location.

Finally, we run the data through the Location Extractor module so we can see the finally feed displayed on a map in Pipes Preview.

Module Output: text

Private String Module

Use this module any time you need to use sensitive data into your Pipe, such as application IDs, usernames and passwords, in a Pipe that you do not want shared with others.

Private String values will only be shown to the owner of the Pipe and will not be copied if the Pipe is cloned (except by the owner).

Example: Run this Pipe | View Source

This example runs a Flickr API search using an application ID only known to the author of the Pipe. When viewing the source of this Pipe the private string will appear blank, although it is used during execution

Copyright © 2014 Yahoo! Inc. All rights reserved.