Re: ***regular expression*** weird

2004-01-19 Thread Rick Anderson
I should apologize for the response I sent. For some reason, the 
original post was showing in my mailbox as "today" so I responded. Now 
it's showing up as having shown up "Nov. 14, 2003" and I see several 
responses from back then! Bizarre. My apologies for any confusion that 
may have caused.

--Rick Anderson
"The only difference between me and a madman,
is that I am not mad." -- Salvador Dali


Re: ***regular expression***

2004-01-18 Thread Rick Anderson
On Friday, November 14, 2003, at 07:25  AM, xweb wrote:

Can someone help me about a regular ?
In which way i can substitute string with
$val1.
I'm not sure I understand exactly what you're asking. Do you mean you 
want to take the value of $url and place it where $val1 occurs in the 
substitution string? If that's what you mean, then surround the part of 
the regex that you want to retain in parentheses and recall it using 
the $1 ... $9 variables.

Like this:

$test = "http://www.google.com\";>Google";

$test =~ s/Google<\/a>/\1/;

print $test;
# test = "http://www.google.com";


--Rick Anderson
"The only difference between me and a madman,
is that I am not mad." -- Salvador Dali


Re: ***regular expression***

2003-11-17 Thread Conrad Schilbe
On 11/17/03 2:52 AM, "xweb" <[EMAIL PROTECTED]> wrote:

> Thanks all but...
> I don't explain well the problem!
> So, i'm processing a very big text file ( from A DB ) in this format
> number|field 1|field2| field 3| etc. Every line is a record.Every line
> contains many url.
> I'm interested about specific url and i don't consider the others.
> 
> while ( $line =~ s/href=\"([^"]+)\"//) {
> $url = $1; ###ALL URL#
> if ($url =~ m/\/[^,]+,([^,]+),([^,]+),[^,]+\.html?$/) {
>  ($var1,$var2)=($1,$2); ###INTERESTING URL AND VALUES
> }
> }
> In this way i obtain two values that interested me! It's works!
> Now i must substitute these url the_link  with
> the_link and then i write to a new file with this
> substitution on all the field of file!
> Can you help me?
> 

The only thing you haven't captured is `the_link`.

 open (FH, "> path/to/new/file") || die "$!\n"; # open new file to write to

 while ( $line =~ /(.*?)<\/a>/) {
 $url = $1; ###ALL URL#
 $the_link = $2;
 if ($url =~ m/\/[^,]+,([^,]+),([^,]+),[^,]+\.html?$/) {
  ($var1,$var2)=($1,$2); ###INTERESTING URL AND VALUES
  print FH "$the_link"; # print to new file
 }
 }
 close(FH)



Re: ***regular expression***

2003-11-17 Thread xweb
Thanks all but...
I don't explain well the problem!
So, i'm processing a very big text file ( from A DB ) in this format
number|field 1|field2| field 3| etc. Every line is a record.Every line
contains many url.
I'm interested about specific url and i don't consider the others.

while ( $line =~ s/href=\"([^"]+)\"//) {
 $url = $1; ###ALL URL#
if ($url =~ m/\/[^,]+,([^,]+),([^,]+),[^,]+\.html?$/) {
   ($var1,$var2)=($1,$2); ###INTERESTING URL AND VALUES
}
}
In this way i obtain two values that interested me! It's works!
Now i must substitute these url the_link  with
the_link and then i write to a new file with this
substitution on all the field of file!
Can you help me?



Re: ***regular expression***

2003-11-15 Thread Dave Gomez
Paolo,
try
s:string:$val1:
note by using :  as the replacement delimiters, you don't have to 
escape the forward slashes.  You will have to worry if the strings you 
have there contain colons tho, although your variable strings should be 
ok

Dave

On Nov 14, 2003, at 8:25 AM, xweb wrote:

Can someone help me about a regular ?
In which way i can substitute string with
$val1.
Thanks
Paolo




Re: ***regular expression***

2003-11-15 Thread Conrad Schilbe
I think this is what you are looking for:

$string =~ s/\.*?\<\/a\>/\$1/;

If you want to capture the link text as well, put brackets around the 2nd
'.*?' and reference it as $2.

Hope that's what you are after.


Conrad



On 11/14/03 8:25 AM, "xweb" <[EMAIL PROTECTED]> wrote:

> Can someone help me about a regular ?
> In which way i can substitute string with
> $val1.
> Thanks
> Paolo
> 



Re: ***regular expression***

2003-11-15 Thread Dan Buettner
I'm guessing you want 'string' to be what follows ''?  If so, 
this ought to work:

$url =~ s/(.*?)<\/a>/$1/i;

Change the 'i' at the end to 'gi' (for global, insensitive) to have 
it process a string with multiple URLs.

HTH,
Dan

Can someone help me about a regular ?
In which way i can substitute string with
$val1.
Thanks
Paolo



***regular expression***

2003-11-15 Thread xweb
Can someone help me about a regular ?
In which way i can substitute string with
$val1.
Thanks
Paolo