Eop

From Yubnub

Checks the value between two tokens in a string. If empty, nothing is returned. If not empty, the whole string is returned.

Contents

Synopsis

eop [STRING] -else [VALUE IF EMPTY] -token [TOKEN VALUE (Default @)]

Examples

eop I like @monkeys@
returns "I like monkeys"
eop I like @@
returns ""
eop I like @@ -else Hello World!
returns "Hello World!"
http://images.google.com/{eop images?q=@%s@}
If %s has a value, you are sent to http://images.google.com/images?q=%s, if it has no value you are sent to http://images.google.com/

Description

This command was created to assist in creating commands that go to one location if given a parameter, and another if empty. It checks between two tokens in a string (default @) for any value (typically %s), and returns the whole string (minus tokens) if not empty. If the value IS empty, nothing is returned (or the value of -else is returned).

You can set the -else parameter to return a string if the value is empty.

By default, the tokens eop looks between are @. This can be changed by setting the -token parameter.

Author

Allen Ormond

Thanks to Stian's unconscious mind for coming up with the idea. http://groups.google.com/group/YubNub/browse_thread/thread/abcf3e5852268d85/

Personal tools