SunQuest
           Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old June 25th, 2004, 05:55 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with regular expression

Hello All,
Not sure where this post belonged so bump it where you like.

I need some freaking help with a regular expression. I have been trying for an hour now and I've only produced a lot of frustration.

I need to pull out the marked line, and since my IP changes, I can only use [dsl.mtry01.pacbell.net]. Can somebody figure out a regexp for this?? I would really appreciate it!

Here's my psudo code:
[anything here up to]dsl.mtry01.pacbell.net$

...
pool-ip.here.bos.east.verizon.net
ar60.lsanca1-ip.here.lsanca1.dsl-verizon.net
adsl-ip.here.dsl.mtry01.pacbell.net <----Need this line
ip.here.dsl.grics.net
...

Thanks a million!
-Kevin

Reply With Quote
  #2  
Old June 25th, 2004, 06:08 AM
Sadrul's Avatar
Sadrul Sadrul is offline
...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2004
Location: In my house :)
Posts: 767 Sadrul User rank is Sergeant (500 - 2000 Reputation Level)Sadrul User rank is Sergeant (500 - 2000 Reputation Level)Sadrul User rank is Sergeant (500 - 2000 Reputation Level)Sadrul User rank is Sergeant (500 - 2000 Reputation Level)Sadrul User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 4 h 37 m 47 sec
Reputation Power: 16
you could `explode` the whole paragraph with '\n' into lines, and then check which line contains the string you are looking for.

-- Adil

Reply With Quote
  #3  
Old June 25th, 2004, 06:12 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well, to be more specific on what I'm using this for, I'm using it to prevent my visits to my site being picked up by AWStats, and they have an option in their config file to enter a regexp with your hostname.

Here is the line from the file:

Code:
SkipHosts="REGEX[^.*\.dsl.mtry01.pacbell.net$]"


Granted that above regexp doesn't work, so I'm trying to find one that will.

Thanks,
-Kevin

Reply With Quote
  #4  
Old June 25th, 2004, 07:19 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,299 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 1 h 54 m 17 sec
Reputation Power: 760
You should escape all the dot characters that are literal dots.
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #5  
Old June 25th, 2004, 07:24 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
me <-- regexp challenged

Can you spell (type) that out for me? If you can re-write the expression above with REGEXP..... with what needs to be there that would be awesome!!

Thanks a bunch,
-Kevin

Reply With Quote
  #6  
Old June 25th, 2004, 07:26 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,299 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 1 h 54 m 17 sec
Reputation Power: 760
You already did it for the first dot character, but here's what I mean:
Code:
SkipHosts="REGEX[^.*\.dsl\.mtry01\.pacbell\.net$]"

Reply With Quote
  #7  
Old June 25th, 2004, 07:28 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool, thanks, I'll give it a try.

Reply With Quote
  #8  
Old June 25th, 2004, 07:34 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've been using this online tool to check my regexp's, and apparently even escaping doesn't work

http://www.bitesizeinc.net/demo.regexp.html

I used the following data on the notepad (each as their own line):

pcp08887104pcs.valenc01.az.comcast.net
mtl-hse-ppp197355.qc.sympatico.ca
adsl-64-164-119-161.dsl.mtry01.pacbell.net
ar60.lsanca1-4.29.76.4.lsanca1.dsl-verizon.net


Thanks,
-Kevin

Reply With Quote
  #9  
Old June 25th, 2004, 07:45 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,299 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 1 h 54 m 17 sec
Reputation Power: 760
You're assuming that AWStats is running the expression on each line, and it's probably not. You need to get rid of the ^ prefix and the $ suffix.
Code:
SkipHosts="REGEX[.*\.dsl\.mtry01\.pacbell\.net]"
I tested it that way on that site and it turned your host red, which I guess means that's what it matched.

Reply With Quote
  #10  
Old June 25th, 2004, 09:59 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I used the expression in your last post, and I got all of the lines up to and including mine, so something wasn't quite right.

Below is taken directly out of the .conf file for AWStats, maybe that will help some.

Quote:
SkipHosts
Version : 1.0+ (5.6+ for REGEX syntax)

# Do not include access from clients that match following criteria.
# If your log file contains IP adresses in host field, you must enter here
# matching IP adresses criteria.
# If DNS lookup is already done in your log file, you must enter here hostname
# criteria, else enter ip address criteria.
# The opposite parameter of "SkipHosts" is "OnlyHosts".
# Note: Use space between each value.
# Note: You can use regular expression values writing value with REGEX[value].
# Change : Effective for new updates only
# Example: "127.0.0.1 REGEX[^192\.168\.] REGEX[^10\.0\.0\.]"
# Example: "localhost REGEX[^.*\.localdomain$]"
# Default: ""
#
SkipHosts=""


Somebody throw me a quarter so I can buy a freaking clue I just want this regexp to work.

Thanks,
-Kevin

Reply With Quote
  #11  
Old June 25th, 2004, 10:56 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,299 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 1 h 54 m 17 sec
Reputation Power: 760
No offense, but I wish you had some experience with regular expressions. I could modify this thing all day w/ trial and error. It seems AWStats treats some of these differently than I'm used to. In PHP/Perl, .* matches any character except new lines, but here it seems to match accross lines too. And since the syntax here uses brackets, I wonder if the expression can. Here's a couple to try.
Code:
SkipHosts="REGEX[[[:alnum:]-]\.dsl\.mtry01\.pacbell\.net]"
Code:
SkipHosts="REGEX[[^\n].*\.dsl\.mtry01\.pacbell\.net]"

Reply With Quote
  #12  
Old June 25th, 2004, 11:09 AM
chapterthreebeg chapterthreebeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 10 chapterthreebeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You were right on the money, except for a *, but you were correct.

Final code is:
Code:
SkipHosts="REGEX[[[:alnum:]-]*.dsl.mtry01.pacbell.net]"


Thanks for all your help, I really appreciate it, I'm gonna go throw it into the AWStats .conf and see if it works.

-Kevin

Reply With Quote
  #13  
Old June 25th, 2004, 11:52 AM
jlk's Avatar
jlk jlk is offline
Perl Jedi
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: New Hampshire
Posts: 108 jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 41 m 53 sec
Reputation Power: 15
I really have to agree with jharnois. It would be a good idea if you familiarized yourself with regular expressions.
Here is a link to a good book you may want to check out.

Regards,

jlk

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Help with regular expression


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump