freelanceprogrammers.org Forum Index » Perl
Regex woes - help, please?
Joined: 21 Sep 2005
Posts: 4
Regex woes - help, please?
This should be obvious, but I`m stuck. If I run this as a standalone Perl
program the regex
works just as I expect it too. But if I run it from the CGI that it`s part of it
fails under
certain conditions. Here is the regular expression:
$line =~ m/captions*(d+)?s*(d+)?s*:s*(.*?)s*([
])
It`s meant to match the follwoing general things
caption: test caption
caption 100: test caption again
caption 123 456: a third test
The first two wrok perfectly in the CGI. The third matches when this is run
standalone
(e.g.,:
#! /usr/bin/perl -w
$_ = "caption 100 200 : test ";
m/captions*(d+)?s*(d+)?s*:s*(.*?)s*([
])/i;
print "match: $& $` 1: $1 2: $2 3: $3 4: $4 ";
but not when in the CGI. In the CGI the thrid test is not matched at all.
What am I missing? Why would this work standalone and not in the CGI?
Thanks.
** Ken **
Joined: 21 May 2004
Posts: 44
Regex woes - help, please?
>>>>> "Ken" == Ken Knight <krk@...> writes:
Ken> What am I missing? Why would this work standalone and not in the CGI?
Is it possible that the third string doesn`t have a , , or
at the end? Are you getting it from a textarea or something?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Joined: 21 Sep 2005
Posts: 4
Regex woes - help, please?
All the samples I posted would include the
(or or ) at the end of
the caption. So
caption 123 456: test caption
Works fine in the standalone bit of Perl I first wrote about, but fails in
the CGI. But
caption: test
(or or ) caption 100: test
(or or )
Both match properly in the standalone and CGI scripts.
Long and short of it: no this isn`t an issue with a missing character at
the end. And, yes, the string for the CGI does come from a textarea box.
Note that the CGI does an awful lot of other stuff with the textarea data
and the ONLY thing that doesn`t work is this one particular special-case
that I`ve been describing (caption [number] [number]: blah blah).
Everything else works as it should.
** Ken **
On 9/21/05 at 9:33 AM, merlyn@... (Randal L. Schwartz) wrote:
>Ken> What am I missing? Why would this work standalone and not in the CGI?
>
>Is it possible that the third string doesn`t have a , , or
at the
>end? Are you getting it from a textarea or something?
-- ** Kenneth Knight Web Design, IT Consultant, Software Engineer **
** krk@... www.wanderingknight.org ** **
Ultralight backpacker www.wanderingknight.org **
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







