out[ ]' :: :guidoin [ ]val replace(','''out[ ]'ab guidoregular expressions can also be used with many of these operations as you'll see below table - python built-in string methods argument description count return the number of non-overlapping occurrences of substring in the string endswithstartswith returns true if string ends with suffix (starts with prefixjoin use string as delimiter for concatenating sequence of other strings index return position of first character in substring if found in the string raises valueer ror if not found find return position of first character of first occurrence of substring in the string like indexbut returns - if not found rfind return position of first character of last occurrence of substring in the string returns - if not found replace replace occurrences of string with another string striprstriplstrip trim whitespaceincluding newlinesequivalent to strip((and rstriplstriprespectivelyfor each element split break string into list of substrings using passed delimiter lowerupper convert alphabet characters to lowercase or uppercaserespectively ljustrjust left justify or right justifyrespectively pad opposite side of string with spaces (or some other fill characterto return string with minimum width regular expressions regular expressions provide flexible way to search or match string patterns in text single expressioncommonly called regexis string formed according to the regular expression language python' built-in re module is responsible for applying regular expressions to stringsi'll give number of examples of its use here the art of writing regular expressions could be of its own and thus is outside the book' scope there are many excellent tutorials and references on the internetsuch as zed shaw' learn regex the hard way (the re module functions fall into three categoriespattern matchingsubstitutionand splitting naturally these are all relateda regex describes pattern to locate in the textwhich can then be used for many purposes let' look at simple examplesuppose wanted to split string with variable number of whitespace characters (tabsspacesand newlinesthe regex describing one or more whitespace characters is \ +string manipulation www it-ebooks info