我正在使用PHP和str_replace函数替换(在这种情况下,删除)RTF文件中的某些代码。它可以很好地替换RTF文件中的某些代码块,但是其他代码块则不能替换,我无法告知原因。
我正在尝试使用此功能从RTF文件中删除段落:
$document = str_replace('CODE-TO-REMOVE-GOES-HERE', '', $document);
此代码可以正常工作:
$document = str_replace('\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 BOLDED CENTERED HEADING}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 ', '', $document);
但是由于某些原因,本节不这样做:
$document = str_replace('\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 This text in the paragraph open(s) non-broken put(s) this is additional sample text that will not remove (CPL \'a7\'a7
100.00[1][x]; 100.23[3])', '', $document);
第一个代码块(删除BOLDED CENTERED HEADING)可以正常工作并删除该行RTF,但是第二个代码块试图删除BOLDED CENTERED HEADING正下方的段落,但不会删除或似乎可以任何东西。
有人能发现两者之间的差异导致一个替代但不是另一个吗?
编辑/更新:
所有文件(rtf,html,php)均以UTF-8编码(根据Notepad ++)。 php.ini有default_charset = "UTF-8"
,. htaccess有AddDefaultCharset UTF-8
这是此时的整个PHP文件。这只是一个测试,看是否可行。它从表单中获取输入并将其插入到RTF中,但是还会尝试删除一些段落-这是我要介绍的部分。我开始认为它与括号有关。
<?php
header('Content-Type: text/html; charset=UTF-8');
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_regex_encoding('UTF-8');
if (isset($_POST['prp'])){
$document = file_get_contents("city-omnibus-template.rtf");
$defendantphp = $_POST['defendanthtml'];
$judgephp = $_POST['judgehtml'];
$crnumphp = $_POST['crnumhtml'];
$adaphp = $_POST['adahtml'];
$attyphp = $_POST['attyhtml'];
$motargdatephp = $_POST['motargdatehtml'];
$deftodisphp = $_POST['deftodishtml'];
$crimedatephp = $_POST['crimedatehtml'];
$motsigndatephp = $_POST['motsigndatehtml'];
$accusdatephp = $_POST['accusdatehtml'];
$allcrimeschargedphp = $_POST['allcrimeschargedhtml'];
if (empty($fax)){
$fax='-';
}
$document = str_replace("#defendantword", $defendantphp, $document);
$document = str_replace("#judgeword", $judgephp, $document);
$document = str_replace("#crnumword", $crnumphp, $document);
$document = str_replace("#adaword", $adaphp, $document);
$document = str_replace("#attyword", $attyphp, $document);
$document = str_replace("#motargdateword", $motargdatephp, $document);
$document = str_replace("#deftodisword", $deftodisphp, $document);
$document = str_replace("#crimedateword", $crimedatephp, $document);
$document = str_replace("#motargdateword", $motsigndatephp, $document);
$document = str_replace("#accusdateword", $accusdatephp, $document);
$document = str_replace("#allcrimeschargedword", $allcrimeschargedphp, $document);
// this one works
$document = str_replace('\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714 ', '', $document);
//this one does not
$document = str_replace('\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge(s) alleged in the accusatory instrument. To the extent that any of
the pending non-felony charge(s) are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information (CPL \'a7\'a7
170.10[4][d]; 170.65[1])', '', $document);
header("Content-type: application/msword");
header("Content-disposition: inline; filename=$defendantphp-Omnibus.doc");
header("Content-length: ".strlen($document));
echo iconv('UTF-8', 'ISO-8859-1', $document);
}
?>
链接到RTF文件:https://drive.google.com/open?id=11sH7RnpuQ1YJq8GFnhclN8kxxBB_SIlo
更多修改:
解决方法-这可能是一种糟糕的方法,但是如果我删除括号()和节符号§(在RTF中用## 118 ##这样的代码代替它)似乎可以使用。 -然后执行另一个str_replace将代码中的(未删除的)标准站立改回括号或节符号。但是,如果有更好的方法,我仍在寻找。
已取得重大进展-一部分仍无法正常工作 一切都在工作,除了最后一节不会替代。我唯一可以说的是与它有什么不同,就是它有一个嵌套列表,但是我不知道为什么这很重要。
这是无法替代的块:
$search3 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 DEFECTIVE INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 6.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant hereby moves, pursuant to CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 170.30}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid3021950 , to dismiss the accusatory or count charging the offense}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 of }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{\rtlch\fcs1 \af0\afs24
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 or count thereof}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
is defective if it is not sufficient on it\rquote s face pursuant to the requirements of CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 100.40 }{\rtlch\fcs1 \af0\afs24
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 170.35[1][a]}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 ;}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 7.\tab}}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
To be sufficient on its face, a local criminal court accusatory which purports to qualify as an \'93information\'94 must satisfy the requirements set forth below:
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 a.\tab}}\pard \ltrpar
\s15\ql \fi-360\li1440\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\ilvl1\adjustright\rin0\lin1440\itap0\pararsid13446461\contextualspace {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 An information \'93
must contain an accusatory part and a factual part. The complainant\rquote s verification of the instrument is deemed to apply only to the }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 factual part thereof and not to the accusatory part.
\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 100.15[1]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 b.\tab}}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 The accusatory part \'93must designate the offense or offenses charged\'94 }{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461
100.15[2]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 c.\tab}The factual part \'93
must contain a statement of the complainant alleging facts of an evidentiary character supporting or tending to support the charges\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.15[3]; see also }{\rtlch\fcs1 \ai\af0\afs24 \ltrch\fcs0
\i\f0\fs24\insrsid13446461\charrsid13446461 People v. Dumas}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 68 NY2d [1986]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 d.\tab}The allegations of the factual part, together with those of any supporting depositions which may accompany it, must \'93
provide reasonable cause to believe that the defendant committed the offense charged in the accusatory part of the information\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.40[1][b]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 e.\tab}Finally, every element of the offense charged and the defendant\rquote s commission thereof must be established by \'93
non-hearsay allegations of the factual part of the information and/or of any supporting depositions\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.40[1][c]; }{\rtlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 \i\f0\fs24\insrsid13446461\charrsid13446461 see also People v. Alejandro}{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 70 NY2d 133 [1987]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 .
\par }\pard\plain \ltrpar\ql \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid13446461 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461
EOL;
$document = str_replace($search3, '', $document);
这是PHP的更新版本,其中包含fyrye的修复程序:
<?php
header('Content-Type: text/html; charset=UTF-8');
if (isset($_POST['prp'])){
$document = file_get_contents("city-omnibus-template.rtf");
// not sure what this does - changes all line endings?
$document = str_replace(["\r\n", "\n"], ["\n", "\r\n"], $document);
$defendantphp = $_POST['defendanthtml'];
$judgephp = $_POST['judgehtml'];
$crnumphp = $_POST['crnumhtml'];
$adaphp = $_POST['adahtml'];
$attyphp = $_POST['attyhtml'];
$motargdatephp = $_POST['motargdatehtml'];
$deftodisphp = $_POST['deftodishtml'];
$crimedatephp = $_POST['crimedatehtml'];
$motsigndatephp = $_POST['motsigndatehtml'];
$accusdatephp = $_POST['accusdatehtml'];
$allcrimeschargedphp = $_POST['allcrimeschargedhtml'];
if (empty($fax)){
$fax='-';
}
$document = str_replace("#defendantword", $defendantphp, $document);
$document = str_replace("#judgeword", $judgephp, $document);
$document = str_replace("#crnumword", $crnumphp, $document);
$document = str_replace("#adaword", $adaphp, $document);
$document = str_replace("#attyword", $attyphp, $document);
$document = str_replace("#motargdateword", $motargdatephp, $document);
$document = str_replace("#deftodisword", $deftodisphp, $document);
$document = str_replace("#crimedateword", $crimedatephp, $document);
$document = str_replace("#motargdateword", $motsigndatephp, $document);
$document = str_replace("#accusdateword", $accusdatephp, $document);
$document = str_replace("#allcrimeschargedword", $allcrimeschargedphp, $document);
// this one is working now
$search1 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714
EOL;
$document = str_replace($search1, '', $document);
// this one is also working now - thanks fyrye
$search2 = <<<'EOL'
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 alleged in the accusatory instrument. To the extent that any of the pending non-felony charge}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7\'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 170.10[4][d]; 170.65[1]}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
EOL;
$document = str_replace($search2, '', $document);
// leaving this in even though it doesn't seem to make a difference
$search3 = str_replace(["\r\n", "\n"], ["\n", "\r\n"], $search3);
// This one still not replacing - most complicated
$search3 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 DEFECTIVE INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 6.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant hereby moves, pursuant to CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 170.30}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid3021950 , to dismiss the accusatory or count charging the offense}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 of }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{\rtlch\fcs1 \af0\afs24
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 or count thereof}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
is defective if it is not sufficient on it\rquote s face pursuant to the requirements of CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 100.40 }{\rtlch\fcs1 \af0\afs24
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 170.35[1][a]}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 ;}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 7.\tab}}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
To be sufficient on its face, a local criminal court accusatory which purports to qualify as an \'93information\'94 must satisfy the requirements set forth below:
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 a.\tab}}\pard \ltrpar
\s15\ql \fi-360\li1440\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\ilvl1\adjustright\rin0\lin1440\itap0\pararsid13446461\contextualspace {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 An information \'93
must contain an accusatory part and a factual part. The complainant\rquote s verification of the instrument is deemed to apply only to the }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 factual part thereof and not to the accusatory part.
\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 100.15[1]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 b.\tab}}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 The accusatory part \'93must designate the offense or offenses charged\'94 }{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461
100.15[2]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 c.\tab}The factual part \'93
must contain a statement of the complainant alleging facts of an evidentiary character supporting or tending to support the charges\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.15[3]; see also }{\rtlch\fcs1 \ai\af0\afs24 \ltrch\fcs0
\i\f0\fs24\insrsid13446461\charrsid13446461 People v. Dumas}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 68 NY2d [1986]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 d.\tab}The allegations of the factual part, together with those of any supporting depositions which may accompany it, must \'93
provide reasonable cause to believe that the defendant committed the offense charged in the accusatory part of the information\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.40[1][b]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 e.\tab}Finally, every element of the offense charged and the defendant\rquote s commission thereof must be established by \'93
non-hearsay allegations of the factual part of the information and/or of any supporting depositions\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.40[1][c]; }{\rtlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 \i\f0\fs24\insrsid13446461\charrsid13446461 see also People v. Alejandro}{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 70 NY2d 133 [1987]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 .
\par }\pard\plain \ltrpar\ql \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid13446461 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461
EOL;
$document = str_replace($search3, '', $document);
header("Content-type: application/msword");
header("Content-disposition: inline; filename=$defendantphp-Omnibus.doc");
echo ($document);
}
?>
答案 0 :(得分:0)
在php中,无论单引号还是双引号封装,反斜杠都是转义序列。
由于您使用单引号封装,因此您的搜索参数为:
\'a7\'a7
仅转义单引号字符,导致:
'a7'a7
但是在RTF文件中实际上是\'a7\'a7
。
要解决此问题,您需要转义反斜杠并使用以下字符引号:
\\\'a7\\\'a7
哪个将转义反斜杠和单引号,从而导致:
\'a7\'a7
此外,最好的做法是始终使用双反斜杠\\
来避免字面反斜杠,以避免出现诸如您遇到的复杂情况。
要指定文字单引号,请使用反斜杠(
\
)对其进行转义。至 指定文字反斜杠,将其加倍(\\
)。的所有其他实例 反斜杠将被视为文字反斜杠:这意味着 您可能会习惯的其他转义序列,例如\ r或\ n 按字面意思输出而不是具有任何特殊含义。 [sic]
$document = str_replace([
// this one works
'\\par }\\pard\\plain \\ltrpar\\qc \\li0\\ri0\\sl480\\slmult1\\widctlpar\\wrapdefault\\aspalpha\\aspnum\\faauto\\adjustright\\rin0\\lin0\\itap0\\pararsid5841714 \\rtlch\\fcs1 \\af0\\afs22\\alang1025 \\ltrch\\fcs0 \\f31506\\fs22\\lang1033\\langfe1033\\cgrid\\langnp1033\\langfenp1033 {
\\rtlch\\fcs1 \\ab\\af0\\afs24 \\ltrch\\fcs0 \\b\\f0\\fs24\\insrsid5841714\\charrsid5841714 PROSECUTION BY INFORMATION}{\\rtlch\\fcs1 \\ab\\af0\\afs24 \\ltrch\\fcs0 \\b\\f0\\fs24\\insrsid5841714 ',
//this one does not (it does now...)
'\\par {\\listtext\\pard\\plain\\ltrpar \\s15 \\rtlch\\fcs1 \\af0 \\ltrch\\fcs0 \\insrsid5841714 \\hich\\af0\\dbch\\af0\\loch\\f0 5.\\tab}}\\pard\\plain \\ltrpar\\s15\\ql \\fi720\\li0\\ri0\\sl480\\slmult1
\\widctlpar\\wrapdefault\\aspalpha\\aspnum\\faauto\\ls2\\adjustright\\rin0\\lin0\\itap0\\pararsid3021950\\contextualspace \\rtlch\\fcs1 \\af0\\afs22\\alang1025 \\ltrch\\fcs0 \\f31506\\fs22\\lang1033\\langfe1033\\cgrid\\langnp1033\\langfenp1033 {\\rtlch\\fcs1 \\af0\\afs24 \\ltrch\\fcs0
\\f0\\fs24\\insrsid5841714 The defendant has entered a plea of not guilty to the charge(s) alleged in the accusatory instrument. To the extent that any of
the pending non-felony charge(s) are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information (CPL \\\'a7\\\'a7
170.10[4][d]; 170.65[1])',
], '', $document);
或者,为了避免转义反斜杠和引号的需要,可以将搜索参数转换为NOWDOC
语法。
该结构非常适合嵌入PHP代码或其他大型块 文本,无需转义。 [sic]
使用nowdoc语法,反斜杠始终按字面意义处理。
$search = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714
EOL;
$document = str_replace($search, '', $document);
$search = <<<'EOL'
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge(s) alleged in the accusatory instrument. To the extent that any of
the pending non-felony charge(s) are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information (CPL \'a7\'a7
170.10[4][d]; 170.65[1])
EOL;
$document = str_replace($search, '', $document);
结果文档:https://drive.google.com/file/d/1Qw8C1S0AAjgZg8xEy5onmSCptNvRGmuh/view?usp=sharing
确保您的PHP编辑器使用DOS行尾 CRLF ,因为您的RTF文件使用 CRLF 。
要确保正确的行尾,您可以使用将搜索参数从DOS转换为UNIX,然后从UNIX转换为DOS。
$search = <<<'EOL'
EOL;
$search = str_replace(["\r\n", "\n"], ["\n", "\r\n"], $search);
这用于在执行替换之前固定搜索文本。请勿在文档字符串上使用。
由于源文档位于echo iconv('UTF-8', 'ISO-8859-1', $document);
中,因此您无需使用UTF-8
。如果无法将UTF-8编码的字符转换为ISO-8859-1,则使用iconv
可能会导致复杂化。
您对mb_http_input('UTF-8');
的使用不正确。用于检索指定类型的输入编码。 type
参数应该是以下各项之一:GET:“ G”; POST:“ P”; COOKIE:“ C”;字符串:“ S”;列表:“ L”;整个列表中的“ I”将返回数组)。
除非在服务器配置中进行了更改,否则默认情况下PHP从5.6+版本开始使用UTF-8。因此,您可以删除多字节字符串功能。
//mb_internal_encoding('UTF-8');
//mb_http_output('UTF-8');
//mb_regex_encoding('UTF-8');
您可以在使用以下方法之前验证设置:
var_dump(array(
mb_internal_encoding(),
mb_http_output(),
mb_regex_encoding(),
));
您还可以删除Content-Length
标头,因为在大多数环境中它们通常是多余的,因为Web服务器在将响应发送给用户代理之前对其进行处理,并且包括响应在内可能导致某些用户代理出现问题。 ,当长度与发送的实际内容不匹配时。
//header("Content-length: ".strlen($document));
在您当前的脚本中,strlen
正在处理UTF-8
编码的字符串,但是响应是ISO-8859-1
编码的字符串。结果指定的Content-length
标头大于实际响应。这可能会导致某些用户代理挂起并期望其他内容。
似乎您更新了RTF内容,因为我找不到search3
文本的多个部分。
但是,问题似乎是由在应用搜索文本替换之前应用占位符替换(#deftodisword
,#judgeword
,#crnumword
,#adaword
等引起的)
这将更改文档字符串的内容,从而导致搜索文本不再匹配。例如,下面的行包含#deftodisword
:
\f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 of }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{\rtlch\fcs1 \af0\afs24
要解决此问题,请在文档上执行搜索替换后,替换占位符 。
作为略微提高性能的最后建议,您可以使用字符串数组组合str_replace
调用。
//returns an array of the combined sanitized search texts
$search = str_replace(["\r\n", "\n"], ["\n", "\r\n"], [$search1, $search2, $search3]);
$document = str_replace($search, '', $document);
$document = str_replace(['#defendantword', '#judgeword'], [$defendantphp, $judgephp], $document);
$search1 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 PROSECUTION BY INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714
EOL;
$search2 = <<<'EOL'
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 5.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant has entered a plea of not guilty to the charge}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 alleged in the accusatory instrument. To the extent that any of the pending non-felony charge}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
are based upon a hearsay complaint, rather than a non-hearsay information, the defendant hereby refuses to consent to be prosecuted by such complaint and demands to be prosecuted by a non-hearsay information }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7\'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 170.10[4][d]; 170.65[1]}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
EOL;
$search3 = <<<'EOL'
\par }\pard\plain \ltrpar\qc \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid5841714 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714\charrsid5841714 DEFECTIVE INFORMATION}{\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid5841714
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5841714 \hich\af0\dbch\af0\loch\f0 6.\tab}}\pard\plain \ltrpar\s15\ql \fi720\li0\ri0\sl480\slmult1
\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin0\itap0\pararsid3021950\contextualspace \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid5841714 The defendant hereby moves, pursuant to CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714 170.30}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid3021950 , to dismiss the accusatory or count charging the offense}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid3021950 of }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 #deftodisword on the ground that it is defective. An accusatory instrument }{\rtlch\fcs1 \af0\afs24
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 or count thereof}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
is defective if it is not sufficient on it\rquote s face pursuant to the requirements of CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 100.40 }{\rtlch\fcs1 \af0\afs24
\ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 170.35[1][a]}{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 ;}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid5841714
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 7.\tab}}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
To be sufficient on its face, a local criminal court accusatory which purports to qualify as an \'93information\'94 must satisfy the requirements set forth below:
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13307306 \hich\af0\dbch\af0\loch\f0 a.\tab}}\pard \ltrpar
\s15\ql \fi-360\li1440\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls2\ilvl1\adjustright\rin0\lin1440\itap0\pararsid13446461\contextualspace {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306 An information \'93
must contain an accusatory part and a factual part. The complainant\rquote s verification of the instrument is deemed to apply only to the }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 factual part thereof and not to the accusatory part.
\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 100.15[1]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13307306
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 b.\tab}}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 The accusatory part \'93must designate the offense or offenses charged\'94 }{
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461
100.15[2]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 c.\tab}The factual part \'93
must contain a statement of the complainant alleging facts of an evidentiary character supporting or tending to support the charges\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.15[3]; see also }{\rtlch\fcs1 \ai\af0\afs24 \ltrch\fcs0
\i\f0\fs24\insrsid13446461\charrsid13446461 People v. Dumas}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 68 NY2d [1986]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 d.\tab}The allegations of the factual part, together with those of any supporting depositions which may accompany it, must \'93
provide reasonable cause to believe that the defendant committed the offense charged in the accusatory part of the information\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0
\f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.40[1][b]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 ;\line
\par {\listtext\pard\plain\ltrpar \s15 \rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid13446461 \hich\af0\dbch\af0\loch\f0 e.\tab}Finally, every element of the offense charged and the defendant\rquote s commission thereof must be established by \'93
non-hearsay allegations of the factual part of the information and/or of any supporting depositions\'94 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 (}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 CPL }{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 \'a7}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 100.40[1][c]; }{\rtlch\fcs1 \ai\af0\afs24 \ltrch\fcs0 \i\f0\fs24\insrsid13446461\charrsid13446461 see also People v. Alejandro}{\rtlch\fcs1
\af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 , 70 NY2d 133 [1987]}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid14111911 )}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461 .
\par }\pard\plain \ltrpar\ql \li0\ri0\sl480\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid13446461 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {
\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \f0\fs24\insrsid13446461
EOL;
//ensure search texts PHP line endings match RTF content
$search = str_replace(["\r\n", "\n"], ["\n", "\r\n"], [$search1, $search2, $search3]);
//replace search texts
$document = str_replace($search, '', $document);
//replace placeholders
$document = str_replace(
['#defendantword', '#judgeword', '#crnumword', '#adaword', '#attyword', '#motargdateword', '#deftodisword', '#crimedateword', '#motargdateword', '#accusdateword', '#allcrimeschargedword'],
[$defendantphp, $judgephp, $crnumphp, $adaphp, $attyphp, $motargdatephp, $deftodisphp, $crimedatephp, $motsigndatephp, $accusdatephp, $allcrimeschargedphp],
$document
);
header('Content-type: application/msword');
header(sprintf('Content-disposition: inline; filename=%s-Omnibus.doc', $defendantphp));
echo $document;