FastNetMon

Friday 16 April 2010

re.search vs re.match (search vs match) в Python

In a nutshell, match() only attempts to match a pattern at the beginning of a string where search() will match a pattern anywhere in a string. For example:


То есть re.match требует, чтобы паттерн подходил ко ВСЕЙ строке, а re.search срабатывает, если хотя бы часть подстроки совпала с паттерном.

No comments :

Post a Comment

Note: only a member of this blog may post a comment.