Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Strings basics
Regular expressions
Modifying strings
20. Remove special characters
Summary

Instruction

As you've seen, we need to replace (~*). But if we would write this for the pattern it would match 0 or more occurrences of ~. So we have to escape the asterisk. You may want to write \*, but this will only escape the asterisk in the string, so to escape it in regex, we need to escape it with an additional backslash, like this: \\*. Put it together and you'll get:

clients$clean_addresses <- sub("~\\*", "", clients$addresses)

Exercise

Use the sub() function to replace ~* in the clean_names column with a single space. Reassign the result to the clean_names column and check it using the head() function.