Re: php preg_match_all - exclude some matches
| From: | Tedd Sperling | Date: | Tue, 16 Nov 2021 19:41:00 +0000 |
| Subject: | Re: php preg_match_all - exclude some matches | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327826@lists.php.net to get a copy of this message | ||
Welcome Gordon:
This group is for posting anything (Q/A) about PHP — not much more.
If you have a question and the person reading your post has the time, then they will provide an
answer.
Of course, that doesn’t stop anyone else from posting or posting a better way.
Your question of:
> Q. i guess 500Kb in a HTML form in $_POST format isn't too much ? Is it Ok ?
I think there is a limit on POST,, but I don’t recall at the moment. Here’s a reference:
https://stackoverflow.com/questions/2364840/what-is-the-size-limit-of-a-post-request
But with files just about any file size that doesn’t overwhelm the server is allowed. I often use
the King James Version of the Bible as text file to load into a single variable to show how large a
string can be.
I’ve also written code to upload the KJV into a database and search it.
I’ve created a demo (with code) for preg_match() as you can view here:
http://citw.lcc.edu/~sperlt/citw185/examples/reg-expression.php
The data array you mention below reminds me of str_replace() — here’s a demo (with code):
http://citw.lcc.edu/~sperlt/citw185/examples/string-replace.php
I think the above will give you a start on solving your problem.
Cheers,
Tedd
> On Nov 13, 2021, at 8:17 PM, gordonisnz@gmail.com wrote:
>
> Hello. Is this php group JUST for development progress for PHP ? or
> can we ask questions here ? it's the only PHP forum I'm on.
>
> I've used preg_match quite a bit, but am unfamiliar with preg_match_all.
>
> Ive not started yet, but I'm going to design a script with a 500Kb
> input text-file, which i want to use preg_match_all on.
>
> Q. i guess 500Kb in a HTML form in $_POST format isn't too much ? Is it Ok ?
>
> In development, I'm going to scan through the data/array & see the
> lines Ive captured for possible exclude text, but even looking at the
> raw data, I see lines I want to EXCLUDE from the results.
> In the live version, I'll use it but have some excluded patterns.
>
> I have these example lines I want to exclude. (inner patterns).
>
> "type":"WORD1"
> "type":"WORD2"
> "type":"WORD3"
>
> Q. Is there a way to use preg_match_all to extract text by an outer
> preg criteria, but if the extracted text also matches one of the
> chosen inner-patterns, it is NOT included in the results.
>
> Can I do this in one go ? Or will I need to do a foreach loop in the
> results to exclude / remove any unwanted sub-patterns after.
>
> I'm not sure yet, but I expect the "wanted" text to be 10-20% of the
> original text.
>
>
> --
>
> Gordon.