regular expressions raw strings lot of the patterns use backslashes howeverbackslashes in strings are used for escape characterslike the newline\ to get backslash in stringwe need to do \this can quickly clutter up regular expression to avoid thisour patterns will be raw stringswhere backslashes can appear as is and don' do anything special to mark string as raw stringpreface it with an like belows 'this is raw string backslashes do not do anything special syntax basic example we start with regular expression that mimics the replace method of strings here is example of using replace to replace all occurrences of abc with *'abcdef abcxyz replace'abc '''*def *xyz here is the regular expression code that does the same thingre sub( 'abc ''''abcdef abcxyz 'square brackets we can use square brackets to indicate that we only want to match certain letters here is an example where we replace every and with asterisksre sub( '[ad''''abcdef '*bc*ef here is another examplewhere an asterisk replaces all occurrences of an abor that is followed by or re sub( '[abc][ '''' ' we can give ranges of values--for example[ -jfor the letters through here are some further examples of rangesrange description [ -zany capital letter [ - any digit [ -za- - any letter or digit slightly shorter way to match any digit is \dinstead of [ - matching any character use dot to match (almostany character here is an examplere sub( ' '''' axb axxb $ '