Ask a Question related to PERL Beginners, Design and Development.
-
Eric Walker #1
matching
I have the following code to find a quote in a string and replace it
with a slashquote.
ie " goes to \"
How do I get it to do more than one substitution in the string.
$_ = $$Rules{$yes}{rule_desc};
s/"/\\"/;
$$Rules{$yes}{rule_desc} = $_;
newbie...
Eric Walker Guest
-
Text Matching
Hi everyone. I am working with an Illustrator 9.0 drawing that was given to my, drawn by someone else. I'm just trying to do some updating to it.... -
Matching/replacing
LoneWolf wrote: What exactly is it you need help with? The only potential problem that I see is that the while loop needs a closing '}' bracket.... -
Matching { } braces ???
In the example below, I'm testing if a string contains either the { or } braces. The problem is that it is causing me a syntax error. The { on the... -
and/or matching question
Hi, On a web form, I have two fields "US_State" and "Other_State". In my perl script I have.... &no_State unless $FORM{'US_State'}; How... -
string matching
I need to remove $b from $a $a = "abc/\def/ghi" ; $b = "abc/\def"; Regards Kamal -
James Edward Gray II #2
Re: matching
On Nov 17, 2003, at 4:18 PM, Eric Walker wrote:
The /g modifier, for "global".> I have the following code to find a quote in a string and replace it
> with a slashquote.
>
> ie " goes to \"
>
> How do I get it to do more than one substitution in the string.
Let's clean that up a little. We don't need $_ here.> $_ = $$Rules{$yes}{rule_desc};
> s/"/\\"/;
> $$Rules{$yes}{rule_desc} = $_;
$$Rules{$yes}{rule_desc} =~ s/"/\\"/g;
How's that?
James
James Edward Gray II Guest
-
Eric Walker #3
Re: matching
Thanks that worked....
On Mon, 2003-11-17 at 15:27, James Edward Gray II wrote:
On Nov 17, 2003, at 4:18 PM, Eric Walker wrote:
The /g modifier, for "global".> I have the following code to find a quote in a string and replace it
> with a slashquote.
>
> ie " goes to \"
>
> How do I get it to do more than one substitution in the string.
Let's clean that up a little. We don't need $_ here.> $_ = $$Rules{$yes}{rule_desc};
> s/"/\\"/;
> $$Rules{$yes}{rule_desc} = $_;
$$Rules{$yes}{rule_desc} =~ s/"/\\"/g;
How's that?
James
Eric Walker Guest
-
Tore Aursand #4
Re: matching
On Mon, 17 Nov 2003 15:18:47 -0700, Eric Walker wrote:
By using the /g modifier.> How do I get it to do more than one substitution in the string.
No. Don't _ever_ try to set $_ yourself, unless you _really_ have to> $_ = $$Rules{$yes}{rule_desc};
(which you don't in this case).
These three lines could easily have been shortened down to only one;> $_ = $$Rules{$yes}{rule_desc};
> s/"/\\"/;
> $$Rules{$yes}{rule_desc} = $_;
$$Rules{$yes}{rule_desc} =~ s/"/\\"/g;
However: Why do you need to quote the " characters?
--
Tore Aursand <tore@aursand.no>
Tore Aursand Guest
-
Eric Walker #5
Re: matching
The /g modifier worked thanks all. I needed to take the quotes in the
file and backslash them so the file could be read into one of our tools
without a problem. Thanks for the short version too. I never thought
of it that way.
Newbie..
On Mon, 2003-11-17 at 20:37, Tore Aursand wrote:
On Mon, 17 Nov 2003 15:18:47 -0700, Eric Walker wrote:By using the /g modifier.> How do I get it to do more than one substitution in the string.
No. Don't _ever_ try to set $_ yourself, unless you _really_ have to> $_ = $$Rules{$yes}{rule_desc};
(which you don't in this case).
These three lines could easily have been shortened down to only one;> $_ = $$Rules{$yes}{rule_desc};
> s/"/\\"/;
> $$Rules{$yes}{rule_desc} = $_;
$$Rules{$yes}{rule_desc} =~ s/"/\\"/g;
However: Why do you need to quote the " characters?
--
Tore Aursand <tore@aursand.no>
--
To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
For additional commands, e-mail: [email]beginners-help@perl.org[/email]
Eric Walker Guest
-
Tim #6
Re: matching
At 03:18 PM 11/17/03 -0700, you wrote:
Put a g before the second semicolon above.>I have the following code to find a quote in a string and replace it
>with a slashquote.
>
>ie " goes to \"
>
>How do I get it to do more than one substitution in the string.
>
>
>$_ = $$Rules{$yes}{rule_desc};
>s/"/\\"/;
>$$Rules{$yes}{rule_desc} = $_;
>
>newbie...
Tim Guest



Reply With Quote

