start page | rating of books | rating of authors | reviews | copyrights

Book HomeJava and XSLTSearch this book

8.205. Text::Balanced

Extracts delimited text sequences from strings. It implements various extract_-named subroutines to capture the delimited string.

In a list context, all Text::Balanced methods return a list that contains the extracted string with delimiters, the remainder of the string, and the parts of the string that were skipped. Text::Balanced is shipped with the Perl source kit as of 5.8.

Text::Balanced implements the following methods.

extract_bracketed

extract_bracketed(text, delimiter)

Extracts the initial substring of textthat is bracketed with delimiters specified by delimiter. Note that delimiter should contain one of (), {}, [], or <>.

extract_codeblock

extract_codeblock(text, delimiter)

Extracts the initial substring of textthat represents a block of Perl code. This code is specified by delimiter, which contains one of (), {}, [], or <>.

extract_delimited

extract_delimited(text, delimiter)

Extracts the initial substring of textthat is delimited by two instances of delimiter.

extract_multiple

extract_multple(text ...)

Extracts the initial substrings of textthat would be extracted by one or more sequential applications of the specified functions.

extract_quotelike

extract_quotelike(text)

Extracts the quoted portion of text.

extract_tagged

extract_tagged(text, "TAG1", "TAG2", undef, nesting_allowed)

Extracts the initial substring of textthat is bounded by an HTML or XML tag:

# Extract HTML tags but don't allow <HTML> to be embedded
($extracted, $left) =
    extract_tagged($text,"<HTML>","</HTML>",
                    undef,{bad=>["<HTML>"]});
extract_multiple($text, ...)
gen_delimited_pat

gen_delimited_pat(q{pattern})

Creates a string that represents the optimized pattern that matches a substring delimited by q{ pattern}.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.