exampleSource <-
"Do you like icecream?
Well, that depends\u2026 Sometimes, when it's..... Nice. Then I do,
but otherwise... not really, actually."
### Default settings:
cat(clean_source(exampleSource));
### First remove existing newlines:
cat(clean_source(exampleSource,
removeNewlines=TRUE));
### Example with a YAML fragment
exampleWithYAML <-
c(
"Do you like icecream?",
"",
"",
"Well, that depends\u2026 Sometimes, when it's..... Nice.",
"Then I do,",
"but otherwise... not really, actually.",
"",
"---",
"This acts as some YAML. So this won't be split.",
"Not real YAML, mind... It just has the delimiters, really.",
"---",
"This is an utterance again."
);
cat(
rock::clean_source(
exampleWithYAML
),
sep="\n"
);
exampleSource <-
"Do you like icecream?
Well, that depends\u2026 Sometimes, when it's..... Nice. Then I do,
but otherwise... not really, actually."
### Simple text replacements:
cat(search_and_replace_in_source(exampleSource,
replacements=list(c("\u2026", "..."),
c("Nice", "Great"))));
### Using a regular expression to capitalize all words following
### a period:
cat(search_and_replace_in_source(exampleSource,
replacements=list(c("\\.(\\s*)([a-z])", ".\\1\\U\\2"))));
exampleSource <-
"Do you like icecream?
Well, that depends\u2026 Sometimes, when it's..... Nice. Then I do,
but otherwise... not really, actually."
### Default settings:
cat(clean_source(exampleSource));
### First remove existing newlines:
cat(clean_source(exampleSource,
removeNewlines=TRUE));
### Example with a YAML fragment
exampleWithYAML <-
c(
"Do you like icecream?",
"",
"",
"Well, that depends\u2026 Sometimes, when it's..... Nice.",
"Then I do,",
"but otherwise... not really, actually.",
"",
"---",
"This acts as some YAML. So this won't be split.",
"Not real YAML, mind... It just has the delimiters, really.",
"---",
"This is an utterance again."
);
cat(
rock::clean_source(
exampleWithYAML
),
sep="\n"
);
Run the code above in your browser using DataLab