Page 1 of 1
preg_match Characer Limit
Posted: Mon Apr 13, 2009 8:15 am
by shiznatix
I have a very simple regex to grab a form field value after grabbing the page via curl. Here is my regex:
Code: Select all
preg_match('#id="__VIEWSTATE" value="(.*?)"#', $content, $matches);
and here is my field that I want the value from:
Code: Select all
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/1123ASdlotsandlotsandlotsofgarbage=" />
Now the value there is a made up one because the real one is 107076 long on average (seriously). Now this value can have everything from / A-Z 0-9 = + ... whatever they want so that is why I am using the (.*?) to just grab anything there. My regex seams to do just fine if I replace the super long value with just something short so I am starting to think that there is some sort of character limit set to what can be returned there. Is this true and if not, why would my regex not be working? If you want me to post a real whole value="" part then no problem, just is so long I didn't want to make it such a spammy post.
Re: preg_match Characer Limit
Posted: Tue Apr 14, 2009 7:24 am
by prometheuzz
shiznatix wrote:I have a very simple regex to grab a form field value after grabbing the page via curl. Here is my regex:
Code: Select all
preg_match('#id="__VIEWSTATE" value="(.*?)"#', $content, $matches);
and here is my field that I want the value from:
Code: Select all
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/1123ASdlotsandlotsandlotsofgarbage=" />
Now the value there is a made up one because the real one is 107076 long on average (seriously). Now this value can have everything from / A-Z 0-9 = + ... whatever they want so that is why I am using the (.*?) to just grab anything there. My regex seams to do just fine if I replace the super long value with just something short so I am starting to think that there is some sort of character limit set to what can be returned there. Is this true and if not, why would my regex not be working? If you want me to post a real whole value="" part then no problem, just is so long I didn't want to make it such a spammy post.
I am not aware of a limitation. Note that the DOT by default does not match new line characters, perhaps there are new line characters in your long value? Try to replace
"(.*?)" with
"([^"]*)".
Re: preg_match Characer Limit
Posted: Tue Apr 14, 2009 9:12 am
by shiznatix
ah that was it, thanks hommie.
Re: preg_match Characer Limit
Posted: Tue Apr 14, 2009 10:43 am
by prometheuzz
shiznatix wrote:ah that was it, thanks hommie.
Good to hear it!