|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
you could `explode` the whole paragraph with '\n' into lines, and then check which line contains the string you are looking for.
-- Adil |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
You already did it for the first dot character, but here's what I mean:
Code:
SkipHosts="REGEX[^.*\.dsl\.mtry01\.pacbell\.net$]" |
|
#7
|
|||
|
|||
|
Cool, thanks, I'll give it a try.
|
|
#8
|
|||
|
|||
|
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 |
|
#9
|
||||
|
||||
|
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]" |
|
#10
|
|||
|
|||
|
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:
Somebody throw me a quarter so I can buy a freaking clue I just want this regexp to work.Thanks, -Kevin |
|
#11
|
||||
|
||||
|
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]" |
|
#12
|
|||
|
|||
|
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 |
|
#13
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > Help with regular expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|