fork download
  1. ex02ChildrenInverse <- function(sentence) {
  2.  
  3. matches <- regmatches(
  4. sentence,
  5. regexec('(.*?) is the (father|mother) of "(.*?)"\\.', sentence))[[1]]
  6.  
  7. parent <- matches[[2]]
  8. male <- matches[[3]] == "father"
  9. child <- matches[[4]]
  10.  
  11. return(list(parent = parent, male = male, child = child))
  12. }
  13. ex02ChildrenInverse('Gudrun is the mother of "Rosamunde ("Rosi")".')
Success #stdin #stdout 0.26s 41212KB
stdin
Standard input is empty
stdout
$parent
[1] "Gudrun"

$male
[1] FALSE

$child
[1] "Rosamunde (\"Rosi\")"