Noah Garrett Wallach wrote:
Okay I am having troubles finding this. in the perldoc modules.
Is there a slicker way to write the following?
if ($line =~ /(Blah1)(.*)/) {
At this point we know that the pattern matched so $1 will contain the
string "Blah1" and $2 will contain a string o
On Fri, Sep 4, 2009 at 23:06, Noah Garrett Wallach wrote:
>
>
> Okay I am having troubles finding this. in the perldoc modules.
> Is there a slicker way to write the following?
>
> if ($line =~ /(Blah1)(.*)/) {
> $blah = $1 if $1;
> $blah2 = $2 if $2;
> }
snip
Okay I am having troubles finding this. in the perldoc modules.
Is there a slicker way to write the following?
if ($line =~ /(Blah1)(.*)/) {
$blah = $1 if $1;
$blah2 = $2 if $2;
}
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For ad
2009/9/4 Noah Garrett Wallach :
> is there any way to search for the following text? In some cases the text
> that I am search could be
>
> "one-two-three-"
> or sometimes the text could be "one-two-"
If you're looking for this specific text then a good answer was
already given, but if that's an
On Fri, Sep 4, 2009 at 04:08, Noah Garrett Wallach wrote:
>
> Hi there,
>
> is there any way to search for the following text? In some cases the text
> that I am search could be
>
> "one-two-three-"
>
> or sometimes the text could be
>
> "one-two-"
>
> what is a nice easy why to parse the above -
Hi there,
is there any way to search for the following text? In some cases the
text that I am search could be
"one-two-three-"
or sometimes the text could be
"one-two-"
what is a nice easy why to parse the above - quotes not included.
--
To unsubscribe, e-mail: beginners-unsubscr...@p
2009/3/12 Deviloper
> Can somebody explain what Backtracking is?
>
> thanx,
> B.
>
In a nutshell, consider the following regex: /foo((b+)ar)/
a regex engine will check every character in the string that is
checked against until it reaches the first "f". When reached, it will
mark the place and ch
This may sound a little bit stupid, but I never ask about "what is up with this
regexps behind the curtain". I was lucky when they did what I was expecting...
But I´m getting old and want to know more. Can somebody explain what
Backtracking is?
thanx,
B.
Duarte Cordeiro wrote:
>
> Hi,
Hello,
> Background:
> I have a @filelist that can have (guess what) several filenames.
> I want to split the filenames in 3 arrays:
> - if the file is in a directory *\templatedata\*\data\ it should go to array1;
> - if the file is in a directory \binaries\* i
.--[ Duarte Cordeiro wrote (2002/10/14 at 16:42:35) ]--
|
| Hi,
|
| Background:
| I have a @filelist that can have (guess what) several filenames.
| I want to split the filenames in 3 arrays:
| - if the file is in a directory *\templatedata\*\data\ it should go
| t
Hi,
Background:
I have a @filelist that can have (guess what) several filenames.
I want to split the filenames in 3 arrays:
- if the file is in a directory *\templatedata\*\data\ it should go to array1;
- if the file is in a directory \binaries\* it should go to array2;
- any other file shou
This is actually a straight-unix grep question. I want to look for
values greater than one in a particular result. What is the
recommended, etc. way to do this?
-Brian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
"John W. Krahn" schrieb:
>
> Andrea Holstein wrote:
> >
> > A matching always return a list of the captured items.
> > On the left side of the assignment is a scalar,
> > so list in a scalar context returns its size.
> ^
> While this is true that is _n
"John W. Krahn" <[EMAIL PROTECTED]> writes:
> $ perl -le'$data = "one two three four five six";
> $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/;
> print "Test 1: $test";
> ($test) = $data =~ /(\S+)\s+(\S+)\s+(\S+)/;
> print "Test 2: $test";
> $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/g;
> print "Test
Andrea Holstein wrote:
>
> Wim De Hul wrote:
> >
> > I tried with:
> >
> > $_ = &snmpget($sysdescr);
> > $IOS_version = /Version (.*?)\, /i;
> >
> > When I do now: print "$1\n"; I get the IOS version
> > But when I type print "$IOS_version\n"; It displays just 1...
> > Can I get r
Wim De Hul wrote:
>
> Hey folks,
Hello,
> I'm writen a script to manage my router configuration.
> To get the IOS version I use regular expressions.
> First, I did it with:
>
> $_ = &getparameter($sysdescr_mib,"System description");# Get
> the SysDescr via SNMP
> /Version /
Wim De Hul wrote:
>
> Hey folks,
>
> I'm writen a script to manage my router configuration.
> To get the IOS version I use regular expressions.
> First, I did it with:
>
> $_ = &getparameter($sysdescr_mib,"System description");# Get
> the SysDescr via SNMP
> /Version /;
>
Hey folks,
I'm writen a script to manage my router configuration.
To get the IOS version I use regular expressions.
First, I did it with:
$_ = &getparameter($sysdescr_mib,"System description");# Get
the SysDescr via SNMP
/Version /;
$_ = $';
(/, /);
$
;
Agustin Rivera
- Original Message -
From: "Etienne Marcotte" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 13, 2001 11:44 AM
Subject: YARQ (Yet Another Regexp Question)
> I saw somewhere on the web a good regexp for removing html tags. Can
x27;t know.
Anyways I'll fool around a little
Etienne
Bob Showalter wrote:
>
> > -Original Message-
> > From: Etienne Marcotte [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, November 13, 2001 2:44 PM
> > To: [EMAIL PROTECTED]
> > Subject: YARQ (Yet A
--- Etienne Marcotte <[EMAIL PROTECTED]> wrote:
> I saw somewhere on the web a good regexp for removing html tags. Can't
> re-find it and it needed some minor mods.
Etienne,
No offense, but there are not good regexes for removing HTML tags. Here are some
legal tags that
break most regular expr
> -Original Message-
> From: Etienne Marcotte [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 13, 2001 2:44 PM
> To: [EMAIL PROTECTED]
> Subject: YARQ (Yet Another Regexp Question)
>
>
> I saw somewhere on the web a good regexp for removing html tags. C
I saw somewhere on the web a good regexp for removing html tags. Can't
re-find it and it needed some minor mods.
Let's say the $line is 'this is a large wordin
size 2';
I played a little around, but it always removed between the first < and
the last > (and I knwo the tutorial on the web said how
Thanks Jeff! Works like a charm!
Be well!
/Martin
* Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) wrote:
> On Nov 3, Martin Karlsson said:
>
> >Could anyone give me a push in the right direction, please?
> >How do I write a regexp that matches double instances of letters (in a
> >file i read into a va
On Nov 3, Martin Karlsson said:
>Could anyone give me a push in the right direction, please?
>How do I write a regexp that matches double instances of letters (in a
>file i read into a variable), e.g. aa LL pp etc. ?
>
>Is there an easy way, or must I use
> (aa|bb|cc|... and so on ) ?
You
Hi all!
Could anyone give me a push in the right direction, please?
How do I write a regexp that matches double instances of letters (in a
file i read into a variable), e.g. aa LL pp etc. ?
Is there an easy way, or must I use
(aa|bb|cc|... and so on ) ?
Thanks for your time!
--
On 23 October 2001 12:21 Jerry Preston [mailto:[EMAIL PROTECTED]] wrote:
> I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I
> can do it with split:
>
> ( $a1,$a2,$a3,$a4 ) = split( /\./, $program );
>
> How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/?
>
my $string = 'pgrap.C4A2S1R.1.gif';
my @s = ($string =~ /(?:\.)*(\w+)(?:\.)*/g);
the arraytores the elements
the //g makes it find more than one match ... post again if you need more
explanation ...
hth
On Tue, Oct 23, 2001 at 06:20:31AM -0500, Jerry Preston shaped the electrons to read:
> Hi,
Hi,
I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I
can do it with split:
( $a1,$a2,$a3,$a4 ) = split( /\./, $program );
How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/?
Thanks,
Jerry
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional c
Andrea Holstein wrote:
>
> ( $a1,$a2,$a3,$a4 ) = $program =~ m/^(.+)\.(.+)\.(.+)\.(.+)$/;
>
Oh, I see, it's a slow solution.
Substitute every (.+) with ([^\.]+) and the pattern matching will be
quite quicker.
Greetings,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional comman
Jerry Preston wrote:
>
> I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I
> can do it with split:
>
> ( $a1,$a2,$a3,$a4 ) = split( /\./, $program );
>
> How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/?
>
Don't use substutions when you want to get parts
Hi,
I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I
can do it with split:
( $a1,$a2,$a3,$a4 ) = split( /\./, $program );
How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/?
Thanks,
Jerry
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional com
Birgit Kellner wrote:
>
> my $header = "Joe DoeThe book I wrote yesterday";
> my $title;
> if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";}
> print "$title\n";
>
> Is there a shorter, simpler, more efficient way to do this? I still need
> $header later on as it is.
>
I try to go anothe
On Oct 19, birgit kellner said:
>> ($title = $header) =~ s//: /;
>
>I had thought of that, but believed that it will also perform the
>substitution on $header. I just tested it, and that doesn't seem to be the
>case. If that's true, there's the solution to my problem.
Doing ($x = $y) =~ s/fo
--On Freitag, 19. Oktober 2001 12:49 -0400 Jeff 'japhy' Pinyan
<[EMAIL PROTECTED]> wrote:
> On Oct 19, birgit kellner said:
>
>> my $header = "Joe DoeThe book I wrote yesterday";
>> my $title;
>> if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";}
>> print "$title\n";
>>
>> Is there a shor
On Oct 19, birgit kellner said:
>my $header = "Joe DoeThe book I wrote yesterday";
>my $title;
>if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";}
>print "$title\n";
>
>Is there a shorter, simpler, more efficient way to do this? I still need
>$header later on as it is.
You could do:
(
try this:
my $title =~ s// /i;
if ($header =~ /(^\S.+)()(\S.+$)/m)
{
$header =~ s///i;
}
print $header;
hope it helps
martin
birgit kellner wrote:
> my $header = "Joe DoeThe book I wrote yesterday";
> my $title;
> if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3
my $header = "Joe DoeThe book I wrote yesterday";
my $title;
if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";}
print "$title\n";
Is there a shorter, simpler, more efficient way to do this? I still need
$header later on as it is.
I quite often have to copy the value of a variable and the
Great stuff. Regexp objects rock. It worked perfectly and helped with some
other things too.
Thanks a lot Jeff.
CC
>From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: claement claementson <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTE
On Sep 27, claement claementson said:
>1. I'm trying to pass a regexp in $bandNameRE through to a while loop, but
>it keeps bailing complaining about an "unrecognised escpape \S", but when I
>put the regexp directly into the condition it's happy. Why is this?
That's because you're using a doub
Hello again,
This is so basic I'm embarrassed to ask. Sorry.
1. I'm trying to pass a regexp in $bandNameRE through to a while loop, but
it keeps bailing complaining about an "unrecognised escpape \S", but when I
put the regexp directly into the condition it's happy. Why is this?
2. The other th
Hi,
I want to perform a simple split operation, but can't get the regular expr
working. Can anybody help me on this?
my $line from a file read is:
xyz abc 12sd "pqr stz" dfg (delimited by blank char).
I'm doing
my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);
and I'm getting
$par4 =
> On Tue, 26 Jun 2001, Tim Wood wrote:
>
> > Drats - just when I got the regexp worked out too...
> > $_=~ m/()/
>
> Until you get to the one that is like
>
>
> a bunch of stuff
>
And of course, when you fix that simple exception,
the next slightly more complicated exception comes
along.
On Tue, 26 Jun 2001, Tim Wood wrote:
> Drats - just when I got the regexp worked out too...
> $_=~ m/()/
Until you get to the one that is like
a bunch of stuff
Which is why the parser module is a good idea -- it can handle
non-idiomatic cases like this.
-- Brett
> Drats - just when I got the regexp worked out too...
> $_=~ m/()/
Kudos for working out the regex that works given your
assumptions. If the web pages you will be parsing are
known to be constrained to the assumptions you've
established, then you're done.
But be aware that your regex will fail
Drats - just when I got the regexp worked out too...
$_=~ m/()/
> > [matching web page links]
> > [using regexes]
>
> Don't use regexes. They aren't the right tools for the task.
>
> Use one of the cpan modules for parsing web pages.
> Some are written specifically for pulling out links.
>
> htt
> [matching web page links]
> [using regexes]
Don't use regexes. They aren't the right tools for the task.
Use one of the cpan modules for parsing web pages.
Some are written specifically for pulling out links.
http://search.cpan.org/
Hi
I'm new to perl and have a question about regexps that hopefully one of you
can help with.
I'm trying to parse out links from web pages, so essentially I have a string
of the form:
So what I want to do is find an expression to match against that.
Secondly, if there is an easy way to put
Hi,
New messages are coming in as I write. Thanks to all.
My error was in assuming that because '.' is a metacharacter, the match
must start with the initial 's'. However as was pointes out (and in
retrospect, it makes perfect sense, the regexp engine is looking for
any single character before t
At 10:10 AM 6/7/01 -0700, Paul wrote:
> . matches the r in supernova
> n+ matches one or more n's, so it matches the n in supernova
> . matches the o in supervova
> .? matches one or no characters, so it matches nothing
> (successfully, twice)
> v* matches any number of v's, includ
--- Martin Weinless <[EMAIL PROTECTED]> wrote:
> take the regexp '.n+..?.?v*.'
>
> By all that is sacred, if we use the string 'supernova', there should
> be no match since there are too many characters before the 'n'
Not true.
. matches the r in supernova
n+ matches one or more n's, so it
Martin,
Let me take a crack at it, and explain it so that it might help some
beginners, too.
I wrote this code:
$text='supernova';
if ($text=~/.n+..?.?v*./) {
print "match.\n";
}
which just takes your regular expression and applies it. The if statement is
true, I ran it just to make sure.
as you expect.
Mik
---
Mik Firestone
Pinky, are you pondering what I am pondering?
Well, I think so Brain, but if we didn't have ears, we would look just
like weasels.
Martin Weinless <[EMAIL PROTECTED]>
06/07/01 11:25 AM
To: <[EMAIL PROTECTED]>
cc:
Since you are not anchoring in way or another(\b or ^ or \W), it meets your
criteria of any character then n then
Wags ;)
-Original Message-
From: Martin Weinless [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 08:25
To: [EMAIL PROTECTED]
Subject: regexp question
Hello
At 08:25 AM 6/7/2001 -0700, Martin Weinless wrote:
>take the regexp '.n+..?.?v*.'
>
>By all that is sacred, if we use the string 'supernova', there should be
>no match since there are too many characters before the 'n'
>
>However, any regexp checking code will report a match.
Atom by atom:
. -
On Thu, Jun 07, 2001 at 08:25:05AM -0700, Martin Weinless wrote:
> take the regexp '.n+..?.?v*.'
>
> By all that is sacred, if we use the string 'supernova', there should be
> no match since there are too many characters before the 'n'
Nope. Consider
supern ova
^^ ^
On Jun 7, Martin Weinless said:
>take the regexp '.n+..?.?v*.'
>
>By all that is sacred, if we use the string 'supernova', there should be
>no match since there are too many characters before the 'n'
>
>However, any regexp checking code will report a match.
You're not saying "the string must sta
Hello,
This is probably not a true beginners question - it refers to an example
that I use in class when we discuss regexps.
Here is the problem:
take the regexp '.n+..?.?v*.'
By all that is sacred, if we use the string 'supernova', there should be
no match since there are too many characters
--- "Gross, Stephan" <[EMAIL PROTECTED]> wrote:
> I wasn't clear last time. I wrote:
> >I want to match the following:
> >1) the letters "PT"
> >2) a space or nothing
> >3) a word that may or may not be in parentheses or even not exist
> >and return item #3 (which may be null)
> >Example:
> >PT
- Original Message -
From: Gross, Stephan <[EMAIL PROTECTED]>
To: 'Beginner Perl' <[EMAIL PROTECTED]>
Sent: Friday, May 11, 2001 5:26 PM
Subject: Regexp Question Again
> I wasn't clear last time. I wrote:
> >I want to match the following:
>
On May 11, Gross, Stephan said:
>I wasn't clear last time. I wrote:
>>I want to match the following:
>>1) the letters "PT"
>>2) a space or nothing
>>3) a word that may or may not be in parentheses or even not exist
>>and return item #3 (which may be null)
>>Example:
>>PT (XYZ) or PT XYZ or PTXYZ
I wasn't clear last time. I wrote:
>I want to match the following:
>1) the letters "PT"
>2) a space or nothing
>3) a word that may or may not be in parentheses or even not exist
>and return item #3 (which may be null)
>Example:
>PT (XYZ) or PT XYZ or PTXYZ or PT
>should return "XYZ" except the la
--- Carl Rogers <[EMAIL PROTECTED]> wrote:
> Not having Perl up and running, would this work with the
> parenthesis??
> $temp = ~ m/PT[\(]*(\w+)[\)]*/;
> $value = $1;
> I'm sure there is a one-line answer, but I'm too new to know.
>
> At 05:13 PM 5/10/2001 -0400, Gross, Stephan wrote:
> >I w
How about this?
if (/PT\s*\(?(\w+)\)?/) {
$value = $1;
}
PTMatches the PT
\s* Matches any number (or no) spaces
\(? Matches one or none ('s
(\w+) Matches one or many word characters
\)? Matches one or none )'s
$1Value caught by (\w+)
I think. .. .. maybe.
> At 05:13 PM 5/10/20
Not having Perl up and running, would this work with the parenthesis??
$temp = ~ m/PT[\(]*(\w+)[\)]*/;
$value = $1;
I'm sure there is a one-line answer, but I'm too new to know.
At 05:13 PM 5/10/2001 -0400, Gross, Stephan wrote:
>I want to match the following:
>1) the letters "PT"
>2) a space o
I want to match the following:
1) the letters "PT"
2) a space or nothing
3) a word that may or may not be in parentheses or even not exist
and return item #3 (which may be null)
Example:
PT (XYZ) or PT XYZ or PTXYZ or PT
should return "XYZ" except the last case, which should return "".
I can do
66 matches
Mail list logo