I'm using PHP and the str_replace function to replace (in this case remove) some code from within an RTF file. It replaces some blocks of code in the RTF file fine, but others do not replace and I cant tell why.
I'm trying to use this function to remove paragraphs from an RTF file:
$document = str_replace('CODE-TO-REMOVE-GOES-HERE', '', $document);
This code works fine:
$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);
but for some reason this section 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 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);
The first block of code (removing the BOLDED CENTERED HEADING) works fine and removes that line RTF, but the second block, which is trying to remove the paragraph directly below the BOLDED CENTERED HEADING, doesn't remove or seem to do anything.
Can anyone spot the difference between these two that is causing one to replace but not the other?
Edit/Update:
all the files (rtf, html, php) are encoded in UTF-8 (according to Notepad++). php.ini has default_charset = "UTF-8"
and .htaccess has AddDefaultCharset UTF-8
Here is the entire PHP file at this point. It's only a test to see if this was possible. It takes inputs from a form and inserts them into the RTF, but also tries to remove some paragraphs - which is the part I'm failing at. I'm starting to think it has something to do with the parentheses.
<?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);
}
?>
Link to RTF file: https://drive.google.com/open?id=11sH7RnpuQ1YJq8GFnhclN8kxxBB_SIlo
More edits:
Workaround - this is probably a terrible way of doing it, but it seems like it works if I remove the parentheses ( ) and section symbol § (replacing it in the RTF with some stand in code like ##118##) - and then doing another str_replace to change the (unremoved) stand in code back to a parentheses or section symbol. But if there's a better way I'm still looking for it.
Significant Progress Made - one part still not working Everything is working except for this last section which won't replace. The only thing I can tell is any different about it is that it has a nested list, but I don't know why that would matter.
Here's the chunk that won't 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);
And here's the updated version of the PHP with fyrye's fixes included:
<?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);
}
?>
In php the backslash is an escape sequence, regardless of single or double quote encapsulation.
Since you are using single quote encapsulation, your search argument with:
\'a7\'a7
Is only escaping the single quote characters, resulting in:
'a7'a7
But is literally \'a7\'a7
in the RTF file.
To resolve the issue, you need to escape the backslash and quote characters with:
\\\'a7\\\'a7
Which will escape the backslash and the single quote resulting in:
\'a7\'a7
Additionally it is best-practice to always escape literal backslashes, by using double backslash \\
, to avoid complications such as the one you encountered.
To specify a literal single quote, escape it with a backslash (
\
). To specify a literal backslash, double it (\\
). All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as \r or \n, will be output literally as specified rather than having any special meaning. [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);
Alternatively, to circumvent the need of escaping backslashes and quotes, you can convert your search argument to the NOWDOC
syntax.
The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. [sic]
Using nowdoc syntax, backslashes are always treated literally.
$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);
Resulting document: https://drive.google.com/file/d/1Qw8C1S0AAjgZg8xEy5onmSCptNvRGmuh/view?usp=sharing
Ensure that your PHP editor is using DOS line endings CRLF, as your RTF file uses CRLF.
To ensure proper line endings you can convert the search argument from DOS to UNIX and then from UNIX to DOS, by using.
$search = <<<'EOL'
EOL;
$search = str_replace(["\r\n", "\n"], ["\n", "\r\n"], $search);
This is used to fix the search text before performing the replacement. Do not use on the document string.
You should not need to use echo iconv('UTF-8', 'ISO-8859-1', $document);
since your source document is in UTF-8
. Using iconv
may cause complications, if a UTF-8 encoded character can not be converted to ISO-8859-1.
Your usage of mb_http_input('UTF-8');
is incorrect. Which is used to retrieve the input encoding of the specified type. The type
argument should be one of "G" for GET, "P" for POST, "C" for COOKIE, "S" for string, "L" for list, and "I" for the whole list (will return array).
Unless changed in your server configurations, PHP uses UTF-8 by default as of version 5.6+. So you can remove the multi-byte string functions.
//mb_internal_encoding('UTF-8');
//mb_http_output('UTF-8');
//mb_regex_encoding('UTF-8');
You can validate the settings before doing so by using:
Example https://3v4l.org/bZukb
var_dump(array(
mb_internal_encoding(),
mb_http_output(),
mb_regex_encoding(),
));
You can also remove the Content-Length
header, as they are generally redundant in most environments, since the web server processes the response prior to sending it the user-agent and including it can cause issues with certain user-agents, when the length does not match the actual content sent.
//header("Content-length: ".strlen($document));
In your current script, the strlen
is processing a UTF-8
encoded string, but the response is an ISO-8859-1
encoded string. Resulting in the specified Content-length
header to be larger than the actual response. Which may cause certain user-agents to hang expecting additional content.
It appears you updated the RTF content, as I am unable to find several portions of the search3
text.
However the issue appears to be caused by applying the placeholder replacements (#deftodisword
, #judgeword
, #crnumword
, #adaword
, etc), prior to applying your search text replacements.
This changes the content of the document string, causing your search text to no longer match. For example the line below contains #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
To resolve the issue, replace the placeholders after executing the search replacements on the document.
As a last suggestion to improve performance slightly, you can combine the str_replace
calls by using string arrays.
Example: https://3v4l.org/TbFa4
//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;