Re: searching and replacing

2005-03-11 Thread John W. Krahn
Stone wrote:
  if (/([0-9.]{6}) set/) {
 s/$1 set/\n-50.2 v \n$1 set/;

You need to escape the period or it will match any character but
newline.  As it is right now you'll match ".FANTA", which isn't what
you want.
A character class is not the same as a regular expression and the period in 
a
character class is just a period and will only match a period while in a
regular expression it is a meta-character that matches any non-newline
character.

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: searching and replacing

2005-03-11 Thread Stone
>if (/([0-9.]{6}) set/) {
>   s/$1 set/\n-50.2 v \n$1 set/;

You need to escape the period or it will match any character but
newline.  As it is right now you'll match ".FANTA", which isn't what
you want.

> Why does this syntax not work? The $1 does not come out.

You can't use variables in the regex portion of your substitution.  If
all you're going to do is a substitution you don't need the if
statement.  However, either way, this is probably the substitution
you're looking for:

s/([0-9\.]{6}) set/\n-50.2 v \n$1 set/;

Have a good one.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: searching and replacing

2005-03-11 Thread FlashMX

Why does this syntax not work? The $1 does not come out.

   if (/([0-9.]{6}) set/) {
  s/$1 set/\n-50.2 v \n$1 set/;





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: searching and replacing

2005-03-11 Thread FlashMX
On Fri, 11 Mar 2005 10:57:19 -0500, FlashMX wrote:

>On Fri, 11 Mar 2005 07:53:30 -0800, John W. Krahn wrote:
>
>>John W. Krahn wrote:
>>> FlashMX wrote:
>>> 
 I need to modify some existing code. The below line checks a file I'm
 reading in and does a search/replace based on the match. Currently
 I'm looking for...

 if (/0 set/) { ...etc.

 Because the "00" can change to different numbers (but always 6
 figures which could include a period) how can I do a wildcard search?

 For example I also need to search for ".0". Or it could also be
 ".45306" or "123456" etc.

 if (/WILDCARD set/) { ...etc.
>>> 
>>> If the decimal point will always be at the beginning of the number:
>>> 
>>> /(?:\.\d{5}|\d{6}) set/
>>
>>Or:
>>
>>/[.\d]\d{5} set/
>>
>>
>
>Not sure if the decimal would always be at the beginning. I guess I have to 
>take into considering it could fall at the beginning, middle or even the end.
>

I tried to search for the word "test" followed by a wordspace and a return then 
the text 123456 text


test 
123456 set

Whats wrong with the syntax?

   if (/test ^\123456 set/) {






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: searching and replacing

2005-03-11 Thread John W. Krahn
FlashMX wrote:
Cool...that worked...thanks
I forgot to mention that one the match is found I do a search and replace
   if (/[0-9.]{6} setgray/) {
  s/.9 set/-50.2 v \n.9 set/;
This is the issue. I need to "grab" the match number (whatever it is) and add 
it into the s/
So...
   if (/[0-9.]{6} setgray/) {
  s/NUMBER_FROM_ABOVE set/-50.2 v \nNUMBER_FROM_ABOVE set/;
if ( s/(?=[\d.]{6} set)/-50.2 v \n/ ) {
do_something_else();
}

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: searching and replacing

2005-03-11 Thread FlashMX
On Fri, 11 Mar 2005 07:53:30 -0800, John W. Krahn wrote:

>John W. Krahn wrote:
>> FlashMX wrote:
>> 
>>> I need to modify some existing code. The below line checks a file I'm
>>> reading in and does a search/replace based on the match. Currently
>>> I'm looking for...
>>>
>>> if (/0 set/) { ...etc.
>>>
>>> Because the "00" can change to different numbers (but always 6
>>> figures which could include a period) how can I do a wildcard search?
>>>
>>> For example I also need to search for ".0". Or it could also be
>>> ".45306" or "123456" etc.
>>>
>>> if (/WILDCARD set/) { ...etc.
>> 
>> If the decimal point will always be at the beginning of the number:
>> 
>> /(?:\.\d{5}|\d{6}) set/
>
>Or:
>
>/[.\d]\d{5} set/
>
>

Not sure if the decimal would always be at the beginning. I guess I have to 
take into considering it could fall at the beginning, middle or even the end.






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: searching and replacing

2005-03-11 Thread FlashMX

>FlashMX wrote:
>> Cool...that worked...thanks
>> 
>> I forgot to mention that one the match is found I do a search and replace
>> 
>>if (/[0-9.]{6} setgray/) {
>>   s/.9 set/-50.2 v \n.9 set/;
>> 
>> This is the issue. I need to "grab" the match number (whatever it is) and 
>> add it into the s/
>> 
>> So...
>> 
>>if (/[0-9.]{6} setgray/) {
>>   s/NUMBER_FROM_ABOVE set/-50.2 v \nNUMBER_FROM_ABOVE set/;
>> 
>> 
>> 
>
>perldoc perlretut
>perldoc perlre
>
>You need to capture the value then...
>
>if (/([0-9.]{6}) setgray/) {
>s/$1 set/-50.2 v \n$1 set/;
>}
>
>Which can be shortened more, but I would leave it readable. Capture 
>values with ()'s and then use those ordered matches by accessing, $1, 
>$2, $3, etc.
>
>http://danconia.org

Hmm...I just tried the above and nothing gets replaced in my output file. Could 
it be the syntax?

   if (/([0-9.]{6}) set/) {
  s/$1 set/-50.2 v \n$1 set/;









-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: searching and replacing

2005-03-11 Thread John W. Krahn
John W. Krahn wrote:
FlashMX wrote:
I need to modify some existing code. The below line checks a file I'm
reading in and does a search/replace based on the match. Currently
I'm looking for...
if (/0 set/) { ...etc.
Because the "00" can change to different numbers (but always 6
figures which could include a period) how can I do a wildcard search?
For example I also need to search for ".0". Or it could also be
".45306" or "123456" etc.
if (/WILDCARD set/) { ...etc.
If the decimal point will always be at the beginning of the number:
/(?:\.\d{5}|\d{6}) set/
Or:
/[.\d]\d{5} set/

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: searching and replacing

2005-03-11 Thread John W. Krahn
FlashMX wrote:
Hi,
Hello,
I need to modify some existing code. The below line checks a file I'm
reading in and does a search/replace based on the match. Currently
I'm looking for...
if (/0 set/) { ...etc.
Because the "00" can change to different numbers (but always 6
figures which could include a period) how can I do a wildcard search?
For example I also need to search for ".0". Or it could also be
".45306" or "123456" etc.
if (/WILDCARD set/) { ...etc.
If the decimal point will always be at the beginning of the number:
/(?:\.\d{5}|\d{6}) set/
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: searching and replacing

2005-03-11 Thread Wiggins d'Anconia
Because it's up-side down.
Why is that?
It makes replies harder to read.
Why not?
Please don't top-post.
(Sherm Pendley, MacOSX List)
FlashMX wrote:
Cool...that worked...thanks
I forgot to mention that one the match is found I do a search and replace
   if (/[0-9.]{6} setgray/) {
  s/.9 set/-50.2 v \n.9 set/;
This is the issue. I need to "grab" the match number (whatever it is) and add 
it into the s/
So...
   if (/[0-9.]{6} setgray/) {
  s/NUMBER_FROM_ABOVE set/-50.2 v \nNUMBER_FROM_ABOVE set/;

perldoc perlretut
perldoc perlre
You need to capture the value then...
if (/([0-9.]{6}) setgray/) {
   s/$1 set/-50.2 v \n$1 set/;
}
Which can be shortened more, but I would leave it readable. Capture 
values with ()'s and then use those ordered matches by accessing, $1, 
$2, $3, etc.

http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: searching and replacing

2005-03-11 Thread FlashMX

Cool...that worked...thanks

I forgot to mention that one the match is found I do a search and replace

   if (/[0-9.]{6} setgray/) {
  s/.9 set/-50.2 v \n.9 set/;

This is the issue. I need to "grab" the match number (whatever it is) and add 
it into the s/

So...

   if (/[0-9.]{6} setgray/) {
  s/NUMBER_FROM_ABOVE set/-50.2 v \nNUMBER_FROM_ABOVE set/;


>On Fri, 11 Mar 2005 09:44:16 -0500, Wiggins d'Anconia wrote:
>
>>FlashMX wrote:
>>> Hi,
>>> 
>>> I need to modify some existing code. The below line checks a file I'm 
>>> reading in and does a search/replace based on the match. Currently I'm 
>>> looking for...
>>> 
>>> if (/0 set/) { ...etc.
>>> 
>>> Because the "00" can change to different numbers (but always 6 figures 
>>> which could include a period) how can I do a wildcard search?
>>> 
>>> For example I also need to search for ".0". Or it could also be 
>>> ".45306" or "123456" etc.
>>> 
>>> if (/WILDCARD set/) { ...etc.
>>> 
>>> 
>>> 
>>> 
>>
>>You can use a character class that includes the digits and a dot, and 
>>match on it six times,
>>
>>if (/[0-9.]{6} set/) {
>>
>>HTH,
>>
>>http://danconia.org
>>
>>-- 
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>>
>
>
>




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: searching and replacing

2005-03-11 Thread Wiggins d'Anconia
FlashMX wrote:
Hi,
I need to modify some existing code. The below line checks a file I'm reading 
in and does a search/replace based on the match. Currently I'm looking for...
if (/0 set/) { ...etc.
Because the "00" can change to different numbers (but always 6 figures 
which could include a period) how can I do a wildcard search?
For example I also need to search for ".0". Or it could also be ".45306" or 
"123456" etc.
if (/WILDCARD set/) { ...etc.


You can use a character class that includes the digits and a dot, and 
match on it six times,

if (/[0-9.]{6} set/) {
HTH,
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



re: searching and replacing

2005-03-11 Thread FlashMX

Hi,

I need to modify some existing code. The below line checks a file I'm reading 
in and does a search/replace based on the match. Currently I'm looking for...

if (/0 set/) { ...etc.

Because the "00" can change to different numbers (but always 6 figures 
which could include a period) how can I do a wildcard search?

For example I also need to search for ".0". Or it could also be ".45306" or 
"123456" etc.

if (/WILDCARD set/) { ...etc.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Searching and replacing text

2004-08-02 Thread Zeus Odin
Could you post the code you have written thus far? It would be a great help.

-ZO

"Chris Richards" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi Everyone,

This is my first post to the list Please be gentle :)

Just so we are all clear... I am completely lost right from the start
with this one. It is far beyond my current Perl skills and I need some
serious help :)

I want to create a script that searches file_b for the first entry in
file_a (router1 in the below example) and once it finds it I would like
it to change the next occurrence of "Parent Submap: Any string" to
"Parent Submap: second entry in file_a (site1 in the below example)"

It would also need to be case-insensitive.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Searching and replacing text

2004-08-02 Thread Chris Richards
Fair enough.

-Chris

-Original Message-
From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
Sent: Monday, 2 August 2004 10:08 PM
To: [EMAIL PROTECTED]
Subject: Re: Searching and replacing text

Chris Richards wrote:
> This is my first post to the list Please be gentle :)

Sure.

> Just so we are all clear... I am completely lost right from the start 
> with this one. It is far beyond my current Perl skills

Oh?

> and I need some serious help :)

Then, this is the most serious (and gentle) help I can think of:

 http://learn.perl.org/



--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Searching and replacing text

2004-08-02 Thread Gunnar Hjalmarsson
Chris Richards wrote:
This is my first post to the list Please be gentle :)
Sure.
Just so we are all clear... I am completely lost right from the
start with this one. It is far beyond my current Perl skills
Oh?
and I need some serious help :)
Then, this is the most serious (and gentle) help I can think of:
http://learn.perl.org/

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]