Click here to get back home

regex back matching

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
regex back matching Ray Muforosky 06-05-2008
Posted by Ray Muforosky on June 5, 2008, 8:53 am
Please log in for more thread options
Hello

I need to match on lines where the 4 quadrant of the ip is even with
one line regex.

For example, if I have

192.68.45.78 daskjaskjf asdfjkasjf asfkasfklh
192.68.34.62 ADKDAK Dkkslaslk jjsdkdldj
192.68.23 INEED HELP PLEASE
192.68.67.34 dkasdfkl kasfkasfkakf
192.68.4.97 flaskfk asfkfafv asf


I should only get:
123.68.45.78 daskjaskjf asdfjkasjf asfkasfklh
192.68.34.62 ADKDAK Dkkslaslk jjsdkdldj
192.68.67.34 dkasdfkl kasfkasfkakf

help and thanks in advance
Ramey

Posted by Dan Rumney on June 5, 2008, 9:14 am
Please log in for more thread options
Ray Muforosky wrote:
> Hello
>
> I need to match on lines where the 4 quadrant of the ip is even with
> one line regex.
[snip]

What do you have so far? There are plenty of pages outlinging regexps
for matching IP addresses... that should prove a good start for you

Posted by Ray Muforosky on June 5, 2008, 10:03 am
Please log in for more thread options
> Ray Muforosky wrote:
> > Hello
>
> > I need to match on lines where the 4 quadrant of the ip is even with
> > one line regex.
>
> =A0 [snip]
>
> What do you have so far? There are plenty of pages outlinging regexps
> for matching IP addresses... that should prove a good start for you

egrep '^[0-9]\.[0-9]\.[0-9]\.([stock here])\s*'
filename

Posted by A. Sinan Unur on June 5, 2008, 10:08 am
Please log in for more thread options
ba9790cf376f@r66g2000hsg.googlegroups.com:

>> Ray Muforosky wrote:
>> > Hello
>>
>> > I need to match on lines where the 4 quadrant of the ip is even with
>> > one line regex.
>>
>>   [snip]
>>
>> What do you have so far? There are plenty of pages outlinging regexps
>> for matching IP addresses... that should prove a good start for you
>
> egrep '^[0-9]\.[0-9]\.[0-9]\.([stock here])\s*'
> filename

What is egrep?

Sinan

--
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Posted by Jim Gibson on June 5, 2008, 11:59 am
Please log in for more thread options

> ba9790cf376f@r66g2000hsg.googlegroups.com:
>
> >> Ray Muforosky wrote:
> >> > Hello
> >>
> >> > I need to match on lines where the 4 quadrant of the ip is even with
> >> > one line regex.
> >>
> >>   [snip]
> >>
> >> What do you have so far? There are plenty of pages outlinging regexps
> >> for matching IP addresses... that should prove a good start for you
> >
> > egrep '^[0-9]\.[0-9]\.[0-9]\.([stock here])\s*'
> > filename
>
> What is egrep?

egrep is a version of the Unix grep program that does regular
expressions.

$ man egrep

"GREP(1)
NAME
grep, egrep, fgrep - print lines matching a pattern

SYNOPSIS
grep [options] PATTERN [FILE...]
grep [options] [-e PATTERN | -f FILE] [FILE...]

DESCRIPTION
Grep searches the named input FILEs (or standard input if no files are
named, or the file name - is given) for lines containing a match to the
given PATTERN. By default, grep prints the matching lines.

In addition, two variant programs egrep and fgrep are available. Egrep
is the same as grep -E. Fgrep is the same as grep -F."


So the OP is asking a question about a Unix utility in a Perl group.

--
Jim Gibson

Similar ThreadsPosted
basic regex back reference May 31, 2006, 4:39 am
Reading a file twice, back to back ? April 15, 2006, 7:27 pm
Regex not matching May 15, 2005, 4:37 am
REGEX NAME Matching.. June 23, 2005, 5:11 pm
Matching substrings within a Regex May 16, 2006, 12:41 pm
regex matching exactly 10 digits November 28, 2006, 8:58 am
get the matching regex pattern March 20, 2008, 9:16 am
Regex matching a string that DOESN'T contain a given word August 31, 2004, 1:07 pm
Regex: Matching Characters NOT in a Certain Range October 4, 2005, 3:17 am
Regex matching a integer in a line February 21, 2007, 1:54 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap