Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

preg_match_all

0 views
Skip to first unread message

alberto

unread,
Dec 28, 2009, 9:07:55 AM12/28/09
to
Hi!
I have a problem. I have to do preg_match_all part of a very long
string and the function does not allow me. the premise that I can not
divide my regex in sub regex.
What should I do?

thanks!

"Álvaro G. Vicario"

unread,
Dec 28, 2009, 10:24:15 AM12/28/09
to
El 28/12/2009 15:07, alberto escribi�:

No code and no error messages so here's my wild guess... Are you getting
the classical "Allowed memory size of XXXXXX bytes exhausted" error message?

I've done some simple testing with a 8 MB string and it can use huge
amounts of memory. You can raise the limit with ini_set() but it may not
be practical to allocate 1GB of RAM for each script instance.

Options I can think of:

1. Use a faster (compiled) language instead of PHP.
2. Preprocess the source string so you can split it safely into smaller
parts.
3. Think of an entirely different algorithm. A regexp that's fine for a
swear word filter may not be appropriate for a spell checker.

--
-- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programaci�n web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

alberto

unread,
Dec 28, 2009, 10:34:33 AM12/28/09
to
On 28 Dic, 16:24, "Álvaro G. Vicario"
<alvaro.NOSPAMTH...@demogracia.com.invalid> wrote:

> El 28/12/2009 15:07, alberto escribió:
>
> > I have a problem. I have to do preg_match_all part of a very long
> > string and the function does not allow me. the premise that I can not
> > divide my regex in sub regex.
> > What should I do?
>
> No code and no error messages so here's my wild guess... Are you getting
> the classical "Allowed memory size of XXXXXX bytes exhausted" error message?
>
> I've done some simple testing with a 8 MB string and it can use huge
> amounts of memory. You can raise the limit with ini_set() but it may not
> be practical to allocate 1GB of RAM for each script instance.
>
> Options I can think of:
>
> 1. Use a faster (compiled) language instead of PHP.
> 2. Preprocess the source string so you can split it safely into smaller
> parts.
> 3. Think of an entirely different algorithm. A regexp that's fine for a
> swear word filter may not be appropriate for a spell checker.
>
> --
> --http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
> -- Mi sitio sobre programación web:http://borrame.com

> -- Mi web de humor satinado:http://www.demogracia.com
> --

thank for the answer Alvaro

I've already changed the ini_set() but still make error.
I try to explain.
I've to do a preg_match_all of a string from poin A to point B the
result should be a string of 290370 character ( number calculated from
strlen function )
If I made a smaller point A to B the preg_math_all works fine.
I hope I have explained correctly as possible

"Álvaro G. Vicario"

unread,
Dec 28, 2009, 11:25:51 AM12/28/09
to
El 28/12/2009 16:34, alberto escribi�:
> On 28 Dic, 16:24, "�lvaro G. Vicario"
> <alvaro.NOSPAMTH...@demogracia.com.invalid> wrote:
>> El 28/12/2009 15:07, alberto escribi�:

>>
>>> I have a problem. I have to do preg_match_all part of a very long
>>> string and the function does not allow me. the premise that I can not
>>> divide my regex in sub regex.
>>> What should I do?
>>
>> No code and no error messages so here's my wild guess... Are you getting
>> the classical "Allowed memory size of XXXXXX bytes exhausted" error message?
>>
>> I've done some simple testing with a 8 MB string and it can use huge
>> amounts of memory. You can raise the limit with ini_set() but it may not
>> be practical to allocate 1GB of RAM for each script instance.
>>
>> Options I can think of:
>>
>> 1. Use a faster (compiled) language instead of PHP.
>> 2. Preprocess the source string so you can split it safely into smaller
>> parts.
>> 3. Think of an entirely different algorithm. A regexp that's fine for a
>> swear word filter may not be appropriate for a spell checker.

> I've already changed the ini_set() but still make error.

What error? What makes you think error messages are not relevant?

> I try to explain.
> I've to do a preg_match_all of a string from poin A to point B the
> result should be a string of 290370 character ( number calculated from
> strlen function )
> If I made a smaller point A to B the preg_math_all works fine.
> I hope I have explained correctly as possible

Alright, let's summarize what we have so far:

1. You have a long string
2. You apply a pattern
3. You get an error

With such information, the only possible advice is: fix your code ;-)


--
-- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programaci�n web: http://borrame.com

alberto

unread,
Dec 28, 2009, 12:00:58 PM12/28/09
to
On 28 Dic, 17:25, "Álvaro G. Vicario"
> --http://alvaro.es- lvaro G. Vicario - Burgos, Spain

> -- Mi sitio sobre programaci n web:http://borrame.com
> -- Mi web de humor satinado:http://www.demogracia.com
> --

becouse there is no message error from preg_match_all.
However I found the error was that I had not inserted / s at the end
of the regex pattern.

thanks

0 new messages