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:Basename instead of a regex?
Joe
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]Sub
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 re
"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 p
Well, there are a couple of issues here. First off, I don't think this
would even compile, because you used /s instead of \s. Secondly, your
regex is looking for:
.* zero or more of any character
(unnecessary, since you didn't anchor the start
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_ qu
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 Messa
$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
Than
$Bill Luebkert
Sent: 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
> [
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
Thanks
Lixin
-Original Message-
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 (defin
This works:
open (INPUT ,"your_input.txt") || die "$!";
open (OUTPUT, "> your_output.txt") || die "$!";
while () {
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
GEND
>
> 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
___
3 11:58 AM
> 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
>
>
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 AM
To: [EMAIL PROTECTED]; [EMAIL PROTE
[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.
h
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]
> > Subj
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)
> {
> o
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 Mess
> -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
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,
>
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, "<
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
a
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 "Fo
, 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&
tml.
Thanks for the idea, 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
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 "Found something interesting:\n", join "\n", @found if @found;
#
which uses t
ctory name to be lib/, while dirname() considers the directory name to be
. (dot).
- Original Message -
From: "Carl Campbell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, June 01, 2001 1:05 AM
Subject: RE: regular expression
Not really a regex approach but here is my submittion:
$OK = "c:\\temp\\test\\test1\\test2";
$your_answer = substr($OK, 0, rindex($OK, "\\"));
# print $your_answer,"\n";
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 31,
No regex in answer here but...
Is this what you want?
use File::Basename;
$OK = "c:\\temp\\test\\test1\\test2";
$OK1 = dirname($OK);
print "dir of
$OK
is
$OK1\n";
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 5:17 PM
Subject
$OK = "c:\\some\\dir\\file";
$OK =~ /(.*)(\\.*)$/;
$OK1 = $1;
...of course it isn't portable across operating systems, and it assumes that
filenames can't contain \.
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: Thursd
> This works great, but now I need to add an (AND, OR) search ability to my
> search.
$query->{Find} =~ /^(.+?)\s+(and|or)\s+(.+?)$/i;
$sql = "SELECT bla, bla FROM table WHERE column LIKE '$1' $2 '$3'"
Of course you'll have to tweak that so a user doesn't enter something
like
and foo
foo and
(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) {
: >
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 : Ho
35 matches
Mail list logo