Re: [pcre-dev] Match for the first 100 charaters of a string

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: Sandhya Sriraj
CC: pcre-dev
Subject: Re: [pcre-dev] Match for the first 100 charaters of a string
On Tue, 9 Oct 2012, Sandhya Sriraj wrote:

> Hi,
> I want to display first 1000 characters of a string (literals are replaced
> by special symbol). I am using pcre library to replace the literal. After
> replacing every literal I am checking for the length of the string and if
> it is > 1000 then stop matching and display the string.
>
> My problem is, Suppose I am sending a string with length 1GB, and if there
> is no literal in that string, pcre will check for the entire string. I want
> to check the match for first 1000 charaters. Is there any way to do this?


The matching function pcre_exec() takes the string as a pointer and a
length. Just set the length to 1000 if you want to search only the first
1000 characters.

Philip

--
Philip Hazel