text3brackets: returns the content of pairs of brackets

Description Usage Arguments Details Value Future Examples

View source: R/rbsa5.code.r

Description

from a text, gives back the contents of a couple of tags (opening and closing tags) indicated by bra under the constraint that the first character of each delimiter be in the column interval of each line indicated with col1 (respectively col2).

Usage

1
2
3
4
5
 
  text3brackets(text,bra=c("{","}"),
                col1=c(1,Inf),col2=c(1,Inf),
                rembra=TRUE,
                which=c(1,Inf)) 

Arguments

text

A character vector containing the text (a component, a line).

bra

character(2) the pair of tags to use.

col1

Positions within a line where the opening bracket has to be found.

col2

Positions within a line where the closing bracket has to be found.

rembra

Must the brackets be removed?

which

Which occurence of tag (not the line numbers) must be returned defined by the the number of the first one and the number of the last one.

Details

Tags cannot be upon two successive lines. The same line can have more than one tag. The result is built by an analysis of the result provided by text3places8word.
When an opening tag is discovered, the following opening tag is not considered before a closing tag has been encountered for the previous one. So the sequence "{ toto {tut} bof} {deux}" will gives two contents, respectively " toto {tut" and "deux".
When an opening tags remains not consistently closed a fatal error is issued with some indication.

Value

A list of texts. Portion within two braces are eliminated.

Future

Think to a way to introduce "end of line" as a possible tag.

Examples

1
2
3
 
  text3brackets(paste(letters,collapse=""),c("j","u")); 
  text3brackets(c(" juste {un","deux ou trois} suffiront !")); 

rbsa documentation built on May 2, 2019, 6:07 p.m.