extract.meta: Extract Template Metadata

Description Usage Arguments Value Examples

View source: R/deprecated.R

Description

Check if template metadata field matches provided format, and return matched value in a list.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
extract.meta(
  x,
  title,
  regex,
  short = NULL,
  trim.white = TRUE,
  mandatory = TRUE,
  default.value = NULL,
  field.length = 1000,
  ...
)

Arguments

x

a string containing template metadata

title

a string containing metadata field title (can be regex-powered)

regex

a string with regular expression to match field value

short

a string with a short name for given metadata field

trim.white

a logical value indicating whether trailing and leading spaces of the given string should be removed before extraction

mandatory

a logical value indicating required field

default.value

fallback to this value if non-mandatory field is not found/malformed

field.length

maximum number of field characters (defaults to 1000)

...

additional parameters for grepl function

Value

a list with matched content, or NULL if the field is not required

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
    rapport:::extract.meta("Name: John Smith", "Name", "[[:alpha:]]+( [[:alpha:]]+)?")
    ## $name
    ## [1] "John Smith"

    rapport:::extract.meta("Name: John", "Name", "[[:alpha:]]+( [[:alpha:]]+)?")
    ## $name
    ## [1] "John"

## End(Not run)

rapport documentation built on April 12, 2021, 1:06 a.m.