Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Regular Expressions & PERL
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
mbirkett
n00b
n00b


Joined: 03 Sep 2002
Posts: 45
Location: Newcastle Upon Tyne

PostPosted: Tue Jan 07, 2003 1:45 pm    Post subject: Regular Expressions & PERL Reply with quote

Hi i am attepting to remove '+' signs from a form posted via a cgi script to another one.

To do this i propose to use:

$subst = /\+\+s/;

to identify and replace '+' with a whitespace character. Will this work, and how to i pass the posted outut through this comparitor?

Any help appreciated,

Cheers,

marc
_________________
I am Thybrush Greepwood, a mighty privet...
Back to top
View user's profile Send private message
cram
Guru
Guru


Joined: 17 Nov 2002
Posts: 312
Location: Saskatoon, Canada

PostPosted: Tue Jan 07, 2003 2:02 pm    Post subject: Reply with quote

A perl regex to replace '+' characters with spaces is
Code:
$string_with_plusses =~ s/+/ /;


Quote:
and how to i pass the posted outut through this comparitor

not sure what you mean by this
_________________
aaarggghhhh.
Good point Chewie.
Back to top
View user's profile Send private message
mbirkett
n00b
n00b


Joined: 03 Sep 2002
Posts: 45
Location: Newcastle Upon Tyne

PostPosted: Tue Jan 07, 2003 2:06 pm    Post subject: Reply with quote

i want to get the values passed from the first script, in the second, then run the comparison to remove '+' signs and display it on the webspage.


Cheers,

amrc
_________________
I am Thybrush Greepwood, a mighty privet...
Back to top
View user's profile Send private message
doug-x07
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2002
Posts: 122
Location: Paris, France

PostPosted: Tue Jan 07, 2003 2:35 pm    Post subject: Reply with quote

Try:
Code:
$string =~ s/\+//g;
If you don't despecialise the plus sign it will not parse. You need the g to catch lines with multiple plus signs otherwise the regexp will just strip the first one.

If I understand your last question correctly on passing the value to another script, just pass it as a parameter to the second script and recover it from @ARGV.
_________________
#! /usr/bin/perl
if( @first != $succeed ) {
post { $question->forum && eval '$answers' };
try { $again } catch { $problem && $resolve };
bless $posters; }
Back to top
View user's profile Send private message
mbirkett
n00b
n00b


Joined: 03 Sep 2002
Posts: 45
Location: Newcastle Upon Tyne

PostPosted: Tue Jan 07, 2003 2:41 pm    Post subject: Reply with quote

Ill give it a try.

Cheers,

Marc
_________________
I am Thybrush Greepwood, a mighty privet...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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