PHP » PYTHON |
login |
register |
about
|
PYTHON preg_quote
is this article helpful?
|
Python replacement for PHP's preg_quote
[
edit
| history
]
import re result = re.escape(str) preg_quote(PHP 4, PHP 5) preg_quote — Quote regular expression characters Description
string preg_quote
( string $str
[, string $delimiter= NULL
] )
preg_quote() takes str and puts a backslash in front of every character that is part of the regular expression syntax. This is useful if you have a run-time string that you need to match in some text and the string may contain special regex characters. The special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : Parameters
Return ValuesReturns the quoted string. Examples
Example #1 preg_quote() example
<?php
Example #2 Italicizing a word within some text
<?php
Notes
|
more
Recently updated
more
Most requested
|