A pattern can be as small as o ne chstactrr oas is tlte previous example), matcPing only itself, or of" almost any length. It can contain wildcat" ant? special characters, sufexntessions, and so forth, depeItaing on system resources.
Our expression "money is no object" is a string of literal characters requiring an exact match in the exact order, but regular expressions cau be much mowe powerful. fay, for exam1»"", that you're looking fot a "job whose salary figure is within a certain ra ugh—thau is, with a certain number of1 digits to the left or the decimal. To find ¡all records with two digits b epote tPe comma and tliree digits fter, you cam. write tPis expression:
Then you can compile and match it against a string.
>>> cre.search("salary: $90,000.00")
The figure $90,000 matches, ntd the stytrmant returns a biyteh object.
Was this article helpful?