Unix and Linux Discussions Tagged with delimiter |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
5 |
6,752 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
15,338 |
Shell Programming and Scripting |
|
|
|
6 |
10,663 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
7,546 |
Shell Programming and Scripting |
|
|
|
7 |
6,568 |
Shell Programming and Scripting |
|
|
|
5 |
3,137 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
959 |
Shell Programming and Scripting |
|
|
|
5 |
1,730 |
Programming |
|
|
|
3 |
8,259 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,764 |
Programming |
|
|
|
2 |
2,213 |
Shell Programming and Scripting |
|
|
|
4 |
1,940 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
5,257 |
Shell Programming and Scripting |
|
|
|
7 |
4,251 |
Shell Programming and Scripting |
|
|
|
13 |
51,480 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,452 |
Shell Programming and Scripting |
|
|
|
5 |
103,970 |
Shell Programming and Scripting |
|
|
|
4 |
4,415 |
Shell Programming and Scripting |
|
|
|
11 |
4,999 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
38,844 |
Shell Programming and Scripting |
|
|
|
7 |
14,451 |
Shell Programming and Scripting |
|
|
|
3 |
2,587 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
10,358 |
Shell Programming and Scripting |
|
|
|
1 |
2,552 |
Shell Programming and Scripting |
|
|
|
4 |
3,921 |
Shell Programming and Scripting |
|
|
|
4 |
2,760 |
Shell Programming and Scripting |
|
|
|
3 |
9,886 |
Shell Programming and Scripting |
|
|
|
5 |
3,536 |
Shell Programming and Scripting |
|
|
|
7 |
20,490 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,689 |
Shell Programming and Scripting |
|
|
|
11 |
3,431 |
Shell Programming and Scripting |
|
|
|
4 |
4,452 |
Shell Programming and Scripting |
|
|
|
0 |
2,633 |
Shell Programming and Scripting |
|
|
|
9 |
4,418 |
Shell Programming and Scripting |
|
|
|
1 |
6,489 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
1,729 |
Shell Programming and Scripting |
|
|
|
4 |
14,276 |
Shell Programming and Scripting |
|
|
|
6 |
6,181 |
Shell Programming and Scripting |
|
|
|
5 |
7,019 |
Shell Programming and Scripting |
|
|
|
4 |
8,089 |
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)