Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Regular expression: Write a regular expression to match patterns in the following strings. Demonstratethatyourregularexpressionindeedmatchedthatpatternbyincludingcodesandresults. Carefully review how the rst problem is solved for you. a.

Regular expression: Write a regular expression to match patterns in the following strings. Demonstratethatyourregularexpressionindeedmatchedthatpatternbyincludingcodesandresults. Carefully review how the rst problem is solved for you.

a. We have a vector vText as follows. Write a regular expression that matches g, og, go or ogo in vText and replace the matches with dots.

vText <- c('google','logo','dig', 'blog', 'boogie' )

Answer:

pattern <- 'o?go?'

gsub(pattern, '.', vText)

## [1] "..le" "l." "di." "bl." "bo.ie" b.

b. Replace only the 4 or 6 digit numbers with the word found in the following vector. Please make sure that 3, 5 or 7 digit numbers do not get changed.

vPhone <- c('874','6783','345345', '32120', '468349', '8149674' )

c. Replace all the characters that are not among the 26 English characters or a space. Please replace with an empty spring.

myText <- "#y%o$u @g!o*t t9h(e) so#lu!tio$n c%or_r+e%ct"

d..Extract the numbers (return only integers) that are followed by the units ml or lb in the following text.

myText <- 'At 10am we had 40ml of water, 5 lb of meat, 3lb of salt and 20 apples.'

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

Students also viewed these Databases questions

Question

What are some metrics for evaluating recruitment and selection?

Answered: 1 week ago

Question

Lo6 Identify several management development methods.

Answered: 1 week ago

Question

LO4 List options for development needs analyses.

Answered: 1 week ago