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 of
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:
On Fri, Sep 4, 2009 at 04:08, Noah Garrett Wallachnoah-l...@enabled.com 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
2009/9/4 Noah Garrett Wallach noah-l...@enabled.com:
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
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
On Fri, Sep 4, 2009 at 23:06, Noah Garrett Wallachnoah-l...@enabled.com 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;
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.
2009/3/12 Deviloper devilo...@slived.net
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
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
.--[ 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
|
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]
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 /;
$_ = $';
(/, /);
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 /;
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 rid of the S_?
A
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 3: $test;
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 font size=2large word/fontin
size 2';
I played a little around, but it always removed between the first and
the last (and I knwo the tutorial on
-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. Can't
re-find it and it needed some
--- 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
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 Another Regexp Question)
I saw somewhere on the web a good regexp
- 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't
re-find it and it needed some minor mods.
Let's say
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 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 want
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
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,
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(\.)/?
You
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
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.
It's
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
Birgit Kellner wrote:
my $header = Joe DoebrbrThe book I wrote yesterday;
my $title;
if ($header =~ /(^\S.+)(brbr)(\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 another way
my $header = Joe DoebrbrThe book I wrote yesterday;
my $title;
if ($header =~ /(^\S.+)(brbr)(\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
try this:
my $title =~ s/brbr/ /i;
if ($header =~ /(^\S.+)(brbr)(\S.+$)/m)
{
$header =~ s/brbr//i;
}
print $header;
hope it helps
martin
birgit kellner wrote:
my $header = Joe DoebrbrThe book I wrote yesterday;
my $title;
if ($header =~ /(^\S.+)(brbr)(\S.+$)/m) {
On Oct 19, birgit kellner said:
my $header = Joe DoebrbrThe book I wrote yesterday;
my $title;
if ($header =~ /(^\S.+)(brbr)(\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:
--On Freitag, 19. Oktober 2001 12:49 -0400 Jeff 'japhy' Pinyan
[EMAIL PROTECTED] wrote:
On Oct 19, birgit kellner said:
my $header = Joe DoebrbrThe book I wrote yesterday;
my $title;
if ($header =~ /(^\S.+)(brbr)(\S.+$)/m) { $title = $1: $3;}
print $title\n;
Is there a shorter, simpler,
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
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
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 PROTECTED]
Subject: Re: very basic regexp question
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 =
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:
A href= /A
So what I want to do is find an expression to match against that.
[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/
Drats - just when I got the regexp worked out too...
$_=~ m/(A)(.*?)( \/A)/
[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.
Drats - just when I got the regexp worked out too...
$_=~ m/(A)(.*?)( \/A)/
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
On Tue, 26 Jun 2001, Tim Wood wrote:
Drats - just when I got the regexp worked out too...
$_=~ m/(A)(.*?)( \/A)/
Until you get to the one that is like
a href=some/url
a bunch of stuff
/a
Which is why the parser module is a good idea -- it can handle
non-idiomatic cases like this.
--
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
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
^^ ^
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:
. - match
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
- 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:
1) the letters PT
2) a space or nothing
3) a word
--- 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 (XYZ) or PT XYZ or
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
49 matches
Mail list logo