Unix and Linux Discussions Tagged with delimiter |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
5 |
9,648 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
17,283 |
Shell Programming and Scripting |
|
|
|
6 |
13,877 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
9,086 |
Shell Programming and Scripting |
|
|
|
7 |
7,847 |
Shell Programming and Scripting |
|
|
|
5 |
3,471 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
1,098 |
Shell Programming and Scripting |
|
|
|
5 |
2,128 |
Programming |
|
|
|
3 |
8,512 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
4,176 |
Programming |
|
|
|
2 |
2,279 |
Shell Programming and Scripting |
|
|
|
4 |
2,088 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
5,878 |
Shell Programming and Scripting |
|
|
|
7 |
4,473 |
Shell Programming and Scripting |
|
|
|
13 |
51,852 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,617 |
Shell Programming and Scripting |
|
|
|
5 |
104,836 |
Shell Programming and Scripting |
|
|
|
4 |
4,520 |
Shell Programming and Scripting |
|
|
|
11 |
5,274 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
39,178 |
Shell Programming and Scripting |
|
|
|
7 |
14,750 |
Shell Programming and Scripting |
|
|
|
3 |
2,680 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
10,494 |
Shell Programming and Scripting |
|
|
|
1 |
2,698 |
Shell Programming and Scripting |
|
|
|
4 |
4,056 |
Shell Programming and Scripting |
|
|
|
4 |
2,862 |
Shell Programming and Scripting |
|
|
|
3 |
10,008 |
Shell Programming and Scripting |
|
|
|
5 |
3,770 |
Shell Programming and Scripting |
|
|
|
7 |
20,722 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,813 |
Shell Programming and Scripting |
|
|
|
11 |
3,596 |
Shell Programming and Scripting |
|
|
|
4 |
4,639 |
Shell Programming and Scripting |
|
|
|
0 |
2,865 |
Shell Programming and Scripting |
|
|
|
9 |
4,538 |
Shell Programming and Scripting |
|
|
|
1 |
6,669 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
1,793 |
Shell Programming and Scripting |
|
|
|
4 |
14,375 |
Shell Programming and Scripting |
|
|
|
6 |
6,292 |
Shell Programming and Scripting |
|
|
|
5 |
7,145 |
Shell Programming and Scripting |
|
|
|
4 |
8,251 |
Shell Programming and Scripting |
PREG_QUOTE(3) 1 PREG_QUOTE(3)
preg_quote - Quote regular expression characters
SYNOPSIS
string preg_quote NULL (string $str, [string $delimiter])
DESCRIPTION
preg_quote(3) 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
o $str
- The input string.
o $delimiter
- If the optional $delimiter is specified, it will also be escaped. This is useful for escaping the delimiter that is required by
the PCRE functions. The / is the most commonly used delimiter.
RETURN VALUES
Returns the quoted (escaped) string.
CHANGELOG
+--------+--------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+--------------------------------+
| 5.3.0 | |
| | |
| | The - character is now quoted |
| | |
+--------+--------------------------------+
EXAMPLES
Example #1
preg_quote(3) example
<?php
$keywords = '$40 for a g3/400';
$keywords = preg_quote($keywords, '/');
echo $keywords; // returns $40 for a g3/400
?>
Example #2
Italicizing a word within some text
<?php
// In this example, preg_quote($word) is used to keep the
// asterisks from having special meaning to the regular
// expression.
$textbody = "This book is *very* difficult to find.";
$word = "*very*";
$textbody = preg_replace ("/" . preg_quote($word, '/') . "/",
"<i>" . $word . "</i>",
$textbody);
?>
NOTES
Note
This function is binary-safe.
SEE ALSO
PCRE Patterns, escapeshellcmd(3).
PHP Documentation Group PREG_QUOTE(3)