Send Close Add comments: (status displays here)
Got it!  This site "www.robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Python find and replace
by RS  admin@robinsnyder.com : 1024 x 640


1. Python find and replace
Python, like most programming languages, has ways to find and replace text.

In general, regular expressions should be used, but sometimes all that is needed is a simple find or replace.

2. Finding text
A common analogy of finding text is that if finding a needle in a haystack.

If text is not find using find, the result is -1 (negative one).

Note that find is a method of the string class (to which a string object belongs). Here is the Python code [#1]

Here is the output of the Python code.


3. Replacing text
Whenever programs write programs, it is often necessary to escape backward slashes to double backward slashes.

Note that replace is a method of the string class (to which a string object belongs). Here is the Python code [#2]

Here is the output of the Python code.


4. End of page

by RS  admin@robinsnyder.com : 1024 x 640