Re: RegExp Problem using Substitutions.

2009-02-24 Thread Rob Dixon
Deviloper wrote: > Hi there! > > I have a string "bbbababbaaassass". I want to get a string without any > double a 'aa' or and without the 'b's. > > but if I do: > > my $s = "bbbababbaaassass"; > $s=~ s/aa|b//g; > > as a result I will get a string "aaassass". > > (I understand WHY I g

Re: RegExp Problem using Substitutions.

2009-02-24 Thread John W. Krahn
John W. Krahn wrote: Deviloper wrote: Hi there! Hello, I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand

Re: RegExp Problem using Substitutions.

2009-02-24 Thread John W. Krahn
Deviloper wrote: Hi there! Hello, I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand WHY I get this result.

RE: RegExp Problem using Substitutions.

2009-02-24 Thread ramesh.marimuthu
Try this: $s=~s/b|ab*a//g; -Original Message- From: Deviloper [mailto:devilo...@slived.net] Sent: Tuesday, February 24, 2009 4:03 PM To: beginners@perl.org Subject: RegExp Problem using Substitutions. Hi there! I have a string "bbbababbaaassass". I want to get a string w

RegExp Problem using Substitutions.

2009-02-24 Thread Deviloper
Hi there! I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand WHY I get this result. But I don´t know how to av

Re: Multiple substitutions from a string into an array

2005-07-04 Thread Mads N. Vestergaard
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey, Ah thanks, that's just what I needed :) I haven't been using m and g together, that was the problem.' Thanks alot. Mads Xavier Noria wrote: | On Jul 4, 2005, at 19:25, Mads N. Vestergaard wrote: | |> My string is "footest test testbartest te

Re: Multiple substitutions from a string into an array

2005-07-04 Thread Ing. Branislav Gerzo
Mads N. Vestergaard [MNV], on Monday, July 04, 2005 at 19:25 (+0200) wrote the following: MNV> My string is "footest test testbartest test MNV> testbaztest test test". I hope this snippet will help you: use strict; use warnings; my $string = qq{footest test testbartest test test

Re: Multiple substitutions from a string into an array

2005-07-04 Thread Xavier Noria
On Jul 4, 2005, at 19:25, Mads N. Vestergaard wrote: My string is "footest test testbartest test testbaztest test test". What I would like to have is to get foo,bar,baz into an array, I've tried to substitute it, but it doesn't seem to work for me. Either I get foo correct and nothing else, o

Multiple substitutions from a string into an array

2005-07-04 Thread Mads N. Vestergaard
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Everybody, I hope you can help me out a bit here. I'm having some problems with multiple substitutions from a string. My string is "footest test testbartest test testbaztest test test". What I would like to have is to get foo,

Re: Using variables in replacement in substitutions

2004-11-20 Thread Robin
On Thu, Nov 18, 2004 at 04:28:40PM +0100, Markus Treinen wrote: > I can't use strict because I simple add a config-file via require and > the variables are simply declared (without my or our). And as it gives > me a lot of warnings, I disabled them, too :-) I hit this very thing today, so I cheat

Re: Using variables in replacement in substitutions

2004-11-19 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Markus Treinen) writes: >> Then don't interpolate it beforehand. (Didn't you get a warning >> about "use of uninitialized value"?) >I can't use strict because I simple add a config-file via require and >the variables are simply declared (without

Re: Using variables in replacement in substitutions

2004-11-18 Thread Gunnar Hjalmarsson
Markus Treinen wrote: Peter Scott wrote: Then don't interpolate it beforehand. (Didn't you get a warning about "use of uninitialized value"?) I can't use strict because I simple add a config-file via require and the variables are simply declared (without my or our). And as it gives me a lot of war

Re: Using variables in replacement in substitutions

2004-11-18 Thread Markus Treinen
Then don't interpolate it beforehand. (Didn't you get a warning about "use of uninitialized value"?) I can't use strict because I simple add a config-file via require and the variables are simply declared (without my or our). And as it gives me a lot of warnings, I disabled them, too :-) But I c

Re: Using variables in replacement in substitutions

2004-11-18 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Markus Treinen) writes: >Hi, >I have the following case: > >- >my $reg_exp = qr/^ONE\.(\d{6})\.THREE$/; >my $replace_with = "FOUR.$1.FIVE"; > >my $example_file = "ONE.123456.THREE"; >$example_file = s/$reg_exp/$replace_with/; >- > >In word

Using variables in replacement in substitutions

2004-11-18 Thread Markus Treinen
Hi, I have the following case: - my $reg_exp = qr/^ONE\.(\d{6})\.THREE$/; my $replace_with = "FOUR.$1.FIVE"; my $example_file = "ONE.123456.THREE"; $example_file = s/$reg_exp/$replace_with/; - In words, I want to reuse substrings from the matched string in the replacement string. Both rege

Re: Substitutions

2004-03-08 Thread John W. Krahn
"Randy W. Sims" wrote: > > On 3/8/2004 8:35 AM, Hemond, Steve wrote: > > > > In an HP/GL2 file, there is a command called SP (select pen) which is > > associated to a pen number from 1 to 64. I have to parse the file and > > insert a command after each select pen command. > > > > Example : > > 106

RE : Substitutions

2004-03-08 Thread Hemond, Steve
[EMAIL PROTECTED] > Sent: Monday, March 08, 2004 8:59 AM > To: Hemond, Steve > Cc: [EMAIL PROTECTED] > Subject: Re: Substitutions > > > On 3/8/2004 8:35 AM, Hemond, Steve wrote: > > > Hi ppl, > > > > In an HP/GL2 file, there is a command called SP

Re: Substitutions

2004-03-08 Thread Randy W. Sims
On 3/8/2004 8:35 AM, Hemond, Steve wrote: Hi ppl, In an HP/GL2 file, there is a command called SP (select pen) which is associated to a pen number from 1 to 64. I have to parse the file and insert a command after each select pen command. Example : 10652PUPD515,10652PUPD515,2536PUSP61PU57531,8270P

Re: Substitutions

2004-03-08 Thread WC -Sx- Jones
Hemond, Steve wrote: Example : 10652PUPD515,10652PUPD515,2536PUSP61PU57531,8270PDPA57 to : 10652PUPD515,10652PUPD515,2536PUSP61;NEW_COMMAND;PU57531,8270PDPA57 My actual way of doing it is : s/SP(\d*)/SP$1;NEW_

Re: Substitutions

2004-03-08 Thread jeffrey_n_Dyke
Hi ppl, In an HP/GL2 file, there is a command called SP (select pen) which is associated to a pen number from 1 to 64. I have to parse the file and insert a command after each select pen command. Example : 10652PUPD515,10652PUPD515,2536PUSP61PU57531,8270PDPA57

Substitutions

2004-03-08 Thread Hemond, Steve
Hi ppl, In an HP/GL2 file, there is a command called SP (select pen) which is associated to a pen number from 1 to 64. I have to parse the file and insert a command after each select pen command. Example : 10652PUPD515,10652PUPD515,2536PUSP61PU57531,8270PDPA57 ---

RE: single quote and substitutions

2002-12-30 Thread Dan Muey
r new values -Original Message- From: Adriano Allora [mailto:[EMAIL PROTECTED]] Sent: Sunday, December 29, 2002 5:21 AM To: [EMAIL PROTECTED] Cc: Dan Muey Subject: Re: single quote and substitutions Venerdì, 27 Dic 2002, alle 20:11 Europe/Rome, Dan Muey ha scritto: > Have you tried

Re: single quote and substitutions

2002-12-29 Thread Adriano Allora
-Original Message- From: Adriano Allora [mailto:[EMAIL PROTECTED]] Sent: Friday, December 27, 2002 1:00 PM To: [EMAIL PROTECTED] Subject: single quote and substitutions Hi to all, I need to substitute in a text a serie of word with another serie of word (for example: when I have the name I want

Re: single quote and substitutions

2002-12-29 Thread John W. Krahn
Adriano Allora wrote: > > Hi to all, Hello, > I need to substitute in a text a serie of word with another serie of > word (for example: when I have the name I want the correct surname). > Modifying a someone else script I wrote this one: > > #!/usr/bin/perl -w > > my $original = '(name1|name2)

Re: single quote and substitutions

2002-12-29 Thread Adriano Allora
Venerdì, 27 Dic 2002, alle 20:11 Europe/Rome, Dan Muey ha scritto: Have you tried doing the regex without the vars? s/(name1|name2)/(surname1|surname2)/g; Does that do what you want? I'd prefer do not do it in this way, because I don't know how many (and what kind of) $originals and $news I'l

RE: single quote and substitutions

2002-12-27 Thread Dan Muey
-Original Message- From: Adriano Allora [mailto:[EMAIL PROTECTED]] Sent: Friday, December 27, 2002 1:00 PM To: [EMAIL PROTECTED] Subject: single quote and substitutions Hi to all, I need to substitute in a text a serie of word with another serie of word (for example: when I have the name

single quote and substitutions

2002-12-27 Thread Adriano Allora
Hi to all, I need to substitute in a text a serie of word with another serie of word (for example: when I have the name I want the correct surname). Modifying a someone else script I wrote this one: #!/usr/bin/perl -w my $original = '(name1|name2)'; my $new = '(surname1|surname2)'; $file_name

Re: A good use for RegEx substitutions?

2002-09-24 Thread John W. Krahn
Jenda Krynicky wrote: > > From: "Steven Arbitman" <[EMAIL PROTECTED]> > > > I have a problem which is simple to state: > > > > Find all prices in a file, multiply them by 2.5, and print out the > > file with the new prices. > > > > It seemed like a good use for substitution at first. > > > > The

RE: A good use for RegEx substitutions?

2002-09-24 Thread nkuipers
Using the /g modifier would be appropriate. Consider using the /e modifier which causes perl to execute code in the "replace-with" part of the s///. The following is from the Camel 3rd Ed, page 209: s/(\d+)/$1 * 2/; #Replaces "42" with "42 * 2" s/(\d+)/$1 * 2/e; #Replaces "42" with "84" Chee

Re: A good use for RegEx substitutions?

2002-09-24 Thread Jenda Krynicky
From: "Steven Arbitman" <[EMAIL PROTECTED]> > I have a problem which is simple to state: > > Find all prices in a file, multiply them by 2.5, and print out the > file with the new prices. > > It seemed like a good use for substitution at first. > > The following successfully finds the prices a

A good use for RegEx substitutions?

2002-09-24 Thread Steven Arbitman
Hi, I have a problem which is simple to state: Find all prices in a file, multiply them by 2.5, and print out the file with the new prices. It seemed like a good use for substitution at first. The following successfully finds the prices and saves them in memory: /\$([0-9.]+)/ (a dollar sign

Re: File substitutions??

2002-03-07 Thread Sudarsan Raghavan
> Thanks for the help!! Unfortunetly this solution only copies the modified > line to the tmp file. I need the all the other data to stay unchanged. > e.g. John:111:0 > Peter:222:0 > Jane:333:0 > > becomes > > John:111:0 > Peter:222:1

RE: File substitutions??

2002-03-07 Thread Jason Larson
> -Original Message- > From: Patrick Bateman [mailto:[EMAIL PROTECTED]] > Subject: File substitutions?? > > Hi everyone Hi! I'm still pretty new myself, so forgive me for not doing this the "Perl way". > > Need help with this please, pretty please!

Re: File substitutions??

2002-03-07 Thread Patrick Bateman
"Sudarsan Raghavan" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Patrick Bateman wrote: > > > Hi everyone > > > > Need help with this please, pretty please!! > > > > I open a file containing this: > > e.g. > > John:111:0 > > Peter:222:0 > > Jane:

Re: File substitutions??

2002-03-07 Thread Sudarsan Raghavan
Patrick Bateman wrote: > Hi everyone > > Need help with this please, pretty please!! > > I open a file containing this: > e.g. > John:111:0 > Peter:222:0 > Jane:333:0 > > Now I select a particular name from an input. > Now comes the part I'm having trouble with. For that name I've

File substitutions??

2002-03-07 Thread Patrick Bateman
Hi everyone Need help with this please, pretty please!! I open a file containing this: e.g. John:111:0 Peter:222:0 Jane:333:0 Now I select a particular name from an input. Now comes the part I'm having trouble with. For that name I've selected how do I increment the count value. e.

Re: Multiple Substitutions with RE on a single line?

2002-01-15 Thread Jeff 'japhy' Pinyan
On Jan 15, John W. Krahn said: >Tim Sargent wrote: >> >>Unaltered (straight text) line: >>--- >>GS5 launches 3 plasma torpedoes (GS5.p1-3), warhead strength 20, speed >> 32, >> >>Formatted line: >>--- >>GS5 launches 3 >> plasma tor

Re: Multiple Substitutions with RE on a single line?

2002-01-15 Thread John W. Krahn
Tim Sargent wrote: > > Hello - Hello, >I'm attempting to develop a simple script that will read a text file and > turn it into an HTML page for me. It's not CGI - I run the script from the > command line and then upload the resultant file to the web server. > >In a nutshell, within th

Re: Multiple Substitutions with RE on a single line?

2002-01-14 Thread Briac Pilpré
Tim Sargent wrote: > I'd prefer an efficient and neat method to do all this, > but am rather stuck. Any pointers that can get me started down the right > path would be greatly appreciated...I know there's an answer out there, I'm > just having a devil of a time finding it. Sorry for the lengthy

Multiple Substitutions with RE on a single line?

2002-01-14 Thread Tim Sargent
Hello - I'm attempting to develop a simple script that will read a text file and turn it into an HTML page for me. It's not CGI - I run the script from the command line and then upload the resultant file to the web server. In a nutshell, within this text file certain words have a specific