Title: Regular expression question
I have a file such as:
My $file = c:\temp\zips\ok.txt;
How can I split the $file to get the only path:
My $dir = c:\temp\zips;
My $file = ok.txt;
Thanks in advance!
Lucy
___
Perl-Win32-Users
Title: Regular expression question
I have a file such as:
My $file = c:\temp\zips\ok.txt;
How can I split the $file to get the only path:
My $dir = c:\temp\zips;
My $file = ok.txt;
Thanks in advance!
Lucy
___
Perl-Win32-Users mailing
Title: Regular expression question
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Cai, Lucy (L.)Sent: Monday, July 31, 2006 17:21To:
Cai, Lucy (L.); perl-win32-users@listserv.ActiveState.com;
perl-unix-users@listserv.ActiveState.com;
[EMAIL PROTECTED];
[EMAIL PROTECTED
Title: Regular expression question
Cai, Lucy (L.) wrote, on Monday, July 31, 2006 8:21
PM
: My
$file = "c:\temp\zips\ok.txt";
: How can
I split the $file to get the only path:
: My $dir
= "c:\temp\zips";: My $file = "ok.txt";
May I
suggest you use File:Ba
Title: Regular expression question
hi
wagner,
try
this:
#/perl
-w
$file =
'c:\temp\zips\foo\foo2\foo3\ok.txt'; @pa = split (/\\/, $file);$file =
$pa[$#pa];
for $i
(0..($#pa-1)) {$dir .=
"$pa[$i]\\";}
print "directory:
$dir\n";print "file: $file\n
At 09:45 PM 4/26/2006 -0400, Cai, Lucy \(L.\) wrote:
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
What I want to do is if this tring include word ucmvob, then return 1,
else return 0.
Hi, all,
I have a question about regular expression:
my code is like this:
**
sub IsPVob
{
my ($Vob) = @_;
my $Output = `cleartool lsvob $Vob`;
die IsPVob can't list vob $Vob if $?;
return
, 2006 6:46 PM
To: perl-win32-users@listserv.ActiveState.com
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Regular expression question
Hi, all,
I have a question about regular expression:
my code is like this:
**
sub
Cai, Lucy (L.) [EMAIL PROTECTED] graced perl with these words of wisdom:
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);
}
**
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public
Hi All,
I am meeting a problem on a regular expression.
My code is like:
$path_elem = $ENV{'CLEARCASE_PN'};
The return value of $path_elem is either
$path_elem = /ccstore/test/test.pl
Or $path_elem = /ccstore/test 1/test 1.pl # there is a space in the
path name including the file name too
On UNIX you have to escape the whitespace, e.g.
/this path/has spaces
would become
/this\ path/has\ spaces
The expression
$path_elem =~ s{(\s)}{\\$1}gio;
should do the trick.
Note that I used {} delimiters (i.e. s{}{}) to make it clearer, since
the data itself contains /s and someone
On UNIX you have to escape the whitespace, e.g.
/this path/has spaces
would become
/this\ path/has\ spaces
The expression
$path_elem =~ s{(\s)}{\\$1}gio;
should do the trick.
Note that I used {} delimiters (i.e. s{}{}) to make it clearer, since
the data itself contains /s and
Richard A. Wells wrote:
On UNIX you have to escape the whitespace, e.g.
/this path/has spaces
would become
/this\ path/has\ spaces
The expression
$path_elem =~ s{(\s)}{\\$1}gio;
The /io is not needed/wanted.
should do the trick.
Note that I used {} delimiters
Richard A. Wells wrote:
$Bill Luebkert wrote:
Richard A. Wells wrote:
[...]
The expression
$path_elem =~ s{(\s)}{\\$1}gio;
The /io is not needed/wanted.
Right about the /i. That's conventional laziness on my part, as it is
usually what I want, though it would be
$Bill Luebkert wrote:
Richard A. Wells wrote:
[...]
The _expression_
$path_elem =~ s{(\s)}{\\$1}gio;
The /io is not needed/wanted.
Right about the /i. That's conventional laziness on my part, as it is
usually what I want, though it would be detrimental in this
$Bill Luebkert graced perl with these words of wisdom:
B. I want to get 1.62 from the string, how can I do it?
Nobody seems to have answered part B.
Actually they did. Sam's for one :
$string = sct-1.62-1;
print $1\n if ($string =~ /^.+-(.+)-.+$/);
You mean $1 captures the part in
Title: A regular expression question
Now I have a string like
My $string = sct-1.62-1;
I have 2 regular _expression_ question here,
A. I want to check whether the format is XXX-XXX-XXX, how can I do it?
B. I want to get 1.62 from the string, how can I do it?
Thanks a lot in advance
Title: A regular expression question
Your format does not match XXX-XXX-XXX so I'll guess you mean three
fields delimited by a dash.
here's one way to do it
$string = "sct-1.62-1";
print "$1\n" if ($string =~ /^.+\-(.+)\-.+$/)
-Original Message
Title: Message
or
even. . .
$string = "sct-1.62-1";print
"$1\n" if ($string =~ /^.+-(.+)-.+$/);
(no
need to use the backslash escape for the dashes; they're not part of a character
class. . .
Sam
Gardner
GTO Application Development
Cai, Lixin (L.) graced perl with these words of wisdom:
My $string = sct-1.62-1;
I have 2 regular expression question here,
A. I want to check whether the format is XXX-XXX-XXX, how can I do it?
B. I want to get 1.62 from the string, how can I do it?
Nobody seems to have answered part B
Ted Schuerzinger wrote:
Cai, Lixin (L.) graced perl with these words of wisdom:
My $string = sct-1.62-1;
I have 2 regular expression question here,
A. I want to check whether the format is XXX-XXX-XXX, how can I do it?
This format doesn't actually match the example given. Maybe he
meant
: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question
Wagner, David --- Senior Programmer Analyst --- WGO wrote:
Hey guys - what's with the HTML ?
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, March 31
$a = this is a (test);
$a =~ s/\W+/_/g;
HTH
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 11:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular expression question
Thanks for the replying
PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular expression question
Thanks for the replying.
I have another question, if I have a string like
$a = this is a (test);
How can I change it to
$a = this_is_a_test;
How can I remove ()?
Thanks
Lixin
-Original Message-
From: [EMAIL PROTECTED
Stacy Doss wrote:
$a = "this is a (test)";
$a =~ s/\W+/_/g;
HTH
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 11:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular _expression_
Wagner, David --- Senior Programmer Analyst --- WGO wrote:
Hey guys - what's with the HTML ?
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 16:49
To: [EMAIL PROTECTED]
Subject: regular expression question
I have a $a which
[EMAIL PROTECTED] schrieb:
I have a txt file like the bottom (I use cleardiff to
compare 2 files and
get this file):
I would recommend that you look at Parse::RecDescent.
Go grab the distribution from CPAN and have a look
at the tutorial - the first example shows you how to
parse a diff.
To: [EMAIL PROTECTED]
Subject: RE: regular expression question
I have another question,
I have string like GENERATION 116, How can I get rid of
, of the
string?
Thanks
Lixin
-Original Message-
From: Todd Hayward [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 11:30
I have another question,
I have string like GENERATION 116, How can I get rid of , of the
string?
If you want to remove the 1st character if it is a , then use this...
$var =~ s///;
$var =~ s/^//; #This removes it only if it is the first character
This works:
open (INPUT ,your_input.txt) || die $!;
open (OUTPUT, your_output.txt) || die $!;
while (INPUT) {
if (m/GENERIC_MULTILINE/) {
$_=GENERATION 116
# Impossible dependency
# Needed to prevent FC4700 to CX-series upgrades
DEPEND Navisphere 2.0.0.0.0
DEPEND Navisphere 1.0.0.0.0
GENDEPEND
-
From: Todd Hayward [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 12:26 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question
Borrowing from the previous example of:
open(fHandle, myfile.txt|);
while (defined ($line = fHandle)){
if ($line ~= /generic/ig
Dear all
I have a txt file like the bottom (I use cleardiff to compare 2 files and
get this file):
I will check whether the line includes ___GENERIC_MULTILINE___ or not, if
it includes, I will get the following information
GENERATION 116
# Impossible dependency
# Needed to prevent FC4700
this helps,
NuTs
- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 28, 2003 9:40 AM
Subject: regular expression question
Dear all
I have a txt file like the bottom (I use cleardiff to compare 2 files and
get this file):
I will check whether
At 10:28 AM 3/20/2003 -0500, you wrote:
Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;
I want to get extension of the file name which is ndu, but I always get
04.1.20.5.002-xlite_katana_free.ndu instead of ndu.
The sub is like:
sub extension
{
my $path = shift;
my $ext =
Hi!
On 20 Mar 2003 at 10:28, [EMAIL PROTECTED] wrote:
Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;
I want to get extension of the file name which is ndu, but I always
get 04.1.20.5.002-xlite_katana_free.ndu instead of ndu.
:
Try the code below. i think it works.
Regards,
PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 9:28 AM
To: [EMAIL PROTECTED]
Subject: Another regular expression question
Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;
I want to get extension of the file name which is ndu, but I always get
04.1.20.5.002
]
Subject: Re: an regular expression question
On 3/19/2003 6:16 PM, [EMAIL PROTECTED] wrote:
All,
A question:
A file like C:\temp\test.txt, how can I get test.txt from this path by
regular expression? I can do it by split function, but I hope I can learn
how to do it by regular expression
I am trying to figure out how to specify or in a regular expression.
Basically, I am specifying the Prompt portion of a telnet session using
Net::Telnet, and I want to match several possible strings that would make up
the prompts. An explanation below:
'/br[0-9][0-9]/' or '/mar[0-9][0-9]/' or
Net::Telnet, and I want to match several possible strings that would make
up
the prompts. An explanation below:
'/br[0-9][0-9]/' or '/mar[0-9][0-9]/' or '/tr[0-9][0-9]/' or
'/ber[0-9]/'
One way is:
if($string =~ /(?:b|t|be|ma)r[0-9]{2}/) {
...
}
The operative operator (heh) here
I want to translate some chaarctersin a
string to its replacement string.
I am doing this.
#**
$inchar =
"\xa2\xa3";$outchar = "\[Cent]\[Pound]";
eval "\$buf =~ tr/$inchar/$outchar/";
#$buf =~ s/$inchar/$outchar/;
print "$buf
On Fri, 22 Nov 2002 [EMAIL PROTECTED] wrote:
all,
I want to check the first line of the file if it is machine or not, like
The first line of the file is:
Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.
my code is like:
if (!-z $file)
{
open(LOG_FILE,
On Fri, 22 Nov 2002, Stovall, Adrian M. wrote:
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 4:38 PM
To: Stovall, Adrian M.; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: regular expression question
I tried
all,
I want to check the first line of the file if it is machine or not, like
The first line of the file is:
Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.
my code is like:
if (!-z $file)
{
open(LOG_FILE, $file) or warn can not open $file:$!\n;
my
Sorry, I did not state quite clear, if it is machine or not, I want to say
if I it is the right file or not...
Lixin
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:07 PM
Cc: [EMAIL PROTECTED]
Subject: regular expression question
Cai Lixin said:
all,
I want to check the first line of the file if it is machine
or not, like
The first line of the file is:
Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.
my code is like:
if (!-z $file)
{
open(LOG_FILE, $file) or warn can
I tried that, it does not work for me!
Lixin
-Original Message-
From: Stovall, Adrian M. [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:28 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: regular expression question
Cai Lixin said:
all,
I want to check
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 4:38 PM
To: Stovall, Adrian M.; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: regular expression question
I tried that, it does not work for me!
Lixin
This code
Yes, it works fine for me!
Thanks a lot!
Have a nice day.
Lixin
-Original Message-
From: Stovall, Adrian M. [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:42 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: regular expression question
-Original Message
while () {
if ( /^#/ ){
print;
}
}
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 3:12 PM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: A regular expression question
I have
I have a cron file which the line looks like this:
00 22 * * * perl -S queue_submit.pl esd-foundry perl -S host-scrubber.pl
#build host scrubber
30 22 * * * perl -S queue_submit.pl esd-foundry perl -S group-scrubber.pl
#build group scrubber
30 22 * * * perl -S queue_submit.pl esd-foundry perl -S
Title: RE: A regular expression question
foreach my $line (FILE)
{
my ($comment) = $line =~ /^\#(.*)$/;
}
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 15:12
To: [EMAIL PROTECTED];
[EMAIL PROTECTED];
[EMAIL
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 12:12 PM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: A regular expression question
I have a cron file which the line looks like this:
00 22 * * * perl -S queue_submit.pl esd-foundry perl -S
[EMAIL PROTECTED] wrote, on Thursday, September 12, 2002 3:12 PM
: I have a cron file which the line looks like this:
:
: 00 22 * * * perl -S queue_submit.pl esd-foundry perl -S host-scrubber.pl
: #build host scrubber
: 30 22 * * * perl -S queue_submit.pl esd-foundry perl -S
: group-scrubber.pl
At 03:11 PM 9/12/2002 -0400, [EMAIL PROTECTED] wrote:
I have a cron file which the line looks like this:
00 22 * * * perl -S queue_submit.pl esd-foundry perl -S host-scrubber.pl
#build host scrubber
30 22 * * * perl -S queue_submit.pl esd-foundry perl -S group-scrubber.pl
#build group scrubber
Cai_lixin wrote:
I want to get the comment after # of each line(not including
#), how could I do this?
Depends. If you might have a # in a command, you'll want everything after
the last #. If you're more likely to have another # in a comment, you want
everything after the first #. (if you
PROTECTED];
[EMAIL PROTECTED]
Subject: A regular expression question
I have a cron file which the line looks like this:
00 22 * * * perl -S queue_submit.pl esd-foundry perl -S host-scrubber.pl
#build host scrubber
30 22 * * * perl -S queue_submit.pl esd-foundry perl -S group-scrubber.pl
#build group
:
Subject:Regular Expression Question
Hello all, I hope some RegEx guru could answer why this stops once it
finds
the first occurrence of the expression.
m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g
This is trying to find web addresses and e-mail addresses from any thing
, I'll poke about with it...if no one sends a yes/no to
the question above.
Joe Y.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Jeffrey
Sent: Monday, March 04, 2002 3:51 PM
To: [EMAIL PROTECTED]
Subject: RE: Regular Expression Question
I've never used
, Richard E.
Sent: Monday, March 04, 2002 3:32 PM
To: 'Joseph Youngquist'; [EMAIL PROTECTED]
Subject: RE: Regular Expression Question
I think that you may need to do this in a while loop:
my @items
while($text =~ m/your string here/g) {
push @items, $1;
}
print join(\n, @items);
HTH,
Ricky
Sorry I sent the old version of the regular expression...the correct one is:
m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?\@?)+))/g
This one gets stuff like [EMAIL PROTECTED]
Thanks again.
PS..all you web folk out there...stick this under your pillow :) handy
little RegEx..once its
Resending because I never saw the message post. Sorry if duplicate.
Try this
#
my $text = this is a website: www.hello-world.com and an e-mail:
[EMAIL PROTECTED];
@found = $text =~ m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g;
print
Dear all,
I have a question about a regular expression, for example
$OK = c:\\temp\\test\\test1\\test2;
How can I do to make me get
$OK1 = c:\\temp\\test\\test1;
That means I do not want the last part of the directory.
Thanks in advance!
Lixin
___
, May 31, 2001 4:17 PM
To: [EMAIL PROTECTED]
Subject: regular expression question
Dear all,
I have a question about a regular expression, for example
$OK = c:\\temp\\test\\test1\\test2;
How can I do to make me get
$OK1 = c:\\temp\\test\\test1;
That means I do not want the last part
: regular expression question
Dear all,
I have a question about a regular expression, for example
$OK = c:\\temp\\test\\test1\\test2;
How can I do to make me get
$OK1 = c:\\temp\\test\\test1;
That means I do not want the last part of the directory.
Thanks in advance!
Lixin
2:17 PM
To: [EMAIL PROTECTED]
Subject: regular expression question
Dear all,
I have a question about a regular expression, for example
$OK = c:\\temp\\test\\test1\\test2;
How can I do to make me get
$OK1 = c:\\temp\\test\\test1;
That means I do not want the last part of the directory.
Thanks
(un-jeopardied)
Wagner-David wrote, on Friday, March 02, 2001 13:08
: steve silvers [mailto:[EMAIL PROTECTED]] wrote
: Say I search on (perl and oracle).
:
: if ($query-{Find} =~ /and/i) {
: Run my sql statement ie: perl and oracle
: }
:
: if ($query-{Find} =~ /or/i) {
: Run my
Im calling a bunch of rows from my database.
In the while loop.
while(my $Dataref = $sth-fetchrow_hashref) {
my %Data = %{$Dataref};
my $text = ($Data{val});
$text = (/(www\.[\w\.\-\/\\=\+\%\:\?]*[a-zA-Z\/0-9])[\001\074]*/)
$emailaddress = $1;
print
steve silvers wrote:
I'm calling a bunch of rows from my database.
In the while loop.
while(my $Dataref = $sth-fetchrow_hashref) {
my %Data = %{$Dataref};
my $text = ($Data{val});
$text = (/(www\.[\w\.\-\/\\=\+\%\:\?]*[a-zA-Z\/0-9])[\001\074]*/)
I am curious, why does this exact same question keep showing up, from
different people (I believe) and with a spaced regularity over and over
again?
I don't know, but you are right.
The most FAQ is : How to send attachments?
The second place is reserved to: How to fetch rows?
The third : How
69 matches
Mail list logo