Re: [PHP] How do I remove a string from another string in a fuzzy way?

[email protected] (Tedd Sperling)
Newsgroups php.general
Message-ID <[email protected]>
On May 20, 2013, at 10:17 PM, Daevid Vincent <[email protected]> wrote:
Initially I was thinking that somehow I could use a simple regex on the
> needle and haystacks to strip out all white space and str_ireplace() them
> that way, but then I don't have a way to put the whitespace back that I can
> see.

Daevid:

Go ahead and strip out the whitespace, but replace it with a delimiter string that is unique and then don't consider that delimiter when comparing strings to strings.

Afterwards, if you want to keep the string (instead of deleting it), then reverse the process adding back in the whitespace and removing the delimiter.

Also, you may want to look into using array_unique() for comparing groupings of several strings (i.e., paragraphs) to other groupings. It works pretty slick for me.

Cheers,

tedd

_____________________
[email protected]
http://sperling.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.