strsub

From DavinciWiki
Jump to: navigation, search


Description

Substring substitution using regular expressions

Arguments and Return Values

Arguments: Three strings or a text buffer and two strings

Return Value: A string or text buffer

Usage

Syntax: strsub(object = STRING/TEXT, match = STRING, subst = STRING)

strsub() traverses a string looking for match and replaces it with subst. For a TEXT object, this operation is done on every row using the same match and subst.

Note: 'match' and 'subst' can contain SED like regular expressions

Examples

dv> poem
Text Buffer with 3 lines of text
    1: The sun was shining on the sea, shining with all it's might
    2: He did his very best to make the billows smooth and bright
    3: And this was odd because it was the middle of the night

dv> strsub(poem,"was","is")
Text Buffer with 3 lines of text
    1: The sun is shining on the sea, shining with all it's might
    2: He did his very best to make the billows smooth and bright
    3: And this is odd because it is the middle of the night

Another example using regular expressions

dv> a = "this is my university and i have $100 dollars"

dv> strsub(a, " [^ ]{2}", " ")
"this   iversity d i ve 00 llars"

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Core Changes

Modified On: 03-27-2006

Personal tools