-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpreg-quote.xml
96 lines (92 loc) · 3.2 KB
/
preg-quote.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?xml version="1.0" encoding="UTF-8"?>
<!-- splitted from ./it/functions/pcre.xml, last change in rev 1.1 -->
<!-- last change to 'preg-quote' in en/ tree in rev 1.2 -->
<!-- EN-Revision: n/a Maintainer: darvina Status: ready -->
<!-- OLD-Revision: 1.78/EN.1.2 -->
<refentry xml:id="function.preg-quote" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>preg_quote</refname>
<refpurpose>Inserisce il carattere di escape nei caratteri delle espressioni regolari</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string </type><methodname>preg_quote</methodname>
<methodparam><type>string </type><parameter>stringa</parameter></methodparam>
<methodparam choice="opt"><type>string </type><parameter>delimitatori</parameter></methodparam>
</methodsynopsis>
<para>
La funzione <function>preg_quote</function> inserisce il carattere
di escape (\) davanti ad ogni carattere presente in <parameter>stringa</parameter>
che sia parte della sintassi di una espressione regolare. Questa
funzione è utile nei casi in cui si generino, durante l'esecuzione,
delle stringhe da usare come criteri di riconoscimento, e queste possano
contenere dei caratteri speciali per le espressioni regolari.
</para>
<para>
Se viene specificato un carattere come parametro <parameter>delimitatore</parameter>,
anche a questo sarà anteposto il carattere di escape (\).
Ciò è particolarmente utile per porre il carattere di escape nei
delimitatori richiesti dalle funzioni PCRE. Il carattere di delimitazione
più comunemente utilizzato è /.
</para>
<para>
I caratteri speciali per le espressioni regolari sono:
<literal>. \\ + * ? [ ^ ] $ ( ) { } = ! < > | :</literal>
</para>
<para>
<example>
<title>Esempio di <function>preg_quote</function></title>
<programlisting role="php">
<![CDATA[
<?php
$keywords = "$40 for a g3/400";
$keywords = preg_quote($keywords, "/");
echo $keywords; // returns \$40 for a g3\/400
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Esempio di come rendere in corsivo una qualsiasi parola di un testo</title>
<programlisting role="php">
<![CDATA[
<?php
// In questo esempio, la funzione preg_quote($word) viene usata
// per impedire agli asterischi di avere il loro significato
// speciale per le espressioni regolari.
$testo = "Questo libro è *molto* difficile da trovare.";
$parola = "*molto*";
$testo = preg_replace("/". preg_quote($parola) . "/",
"<i>" . $parola . "</i>",
$testo);
?>
]]>
</programlisting>
</example>
</para>
¬e.bin-safe;
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->