1 |
Hi, |
2 |
|
3 |
On Tue, 2008-06-03 at 17:39 +1000, Adam Carter wrote: |
4 |
> I want to filter the strings; ? <something> http:// or ? <something? |
5 |
> https:// or ? <something> ftp:// from URLs in apache. I know i need to |
6 |
> escape ? but i'm not sure about / |
7 |
|
8 |
/ needs to be escaped in perl if your regex delimiters are / as well, |
9 |
but here you use ' so I would _hope_ that you don't need \/\/ sort of |
10 |
syntax. YMMV. |
11 |
|
12 |
> and i've used '(something|otherthing|whatever)' to make the 'or's |
13 |
> work. |
14 |
|
15 |
I usually do perl, but it should be the same... Actually on reading |
16 |
further, "Apache uses Perl Compatible Regular Expressions provided by |
17 |
the PCRE library." Neat. You should be viewing this with a fixed width |
18 |
font too :) |
19 |
|
20 |
> <LocationMatch '(\?.*http:\/\/|\?.*https:\/\/|\?.*ftp"\/\/)'> |
21 |
typo here==============================================^ |
22 |
|
23 |
how about taking the common bits out of the () |
24 |
'\?.*(http|https|ftp)://' |
25 |
|
26 |
and it's good practise to use ^ if that's what you're expecting: |
27 |
'^\?.*(http|https|ftp)://' |
28 |
|
29 |
> Order allow,deny |
30 |
> Deny from all |
31 |
> </LocationMatch> |
32 |
> |
33 |
> is that regex correct? Will egrep use the exact same regex syntax (so |
34 |
> i can use it to check?) |
35 |
|
36 |
I think they're essentially the same, with the exception of some classes |
37 |
(like [:punct:] or [\d]). egrep may need some extra escaping so as not |
38 |
to confuse your shell. The best way to test is to use the real program, |
39 |
so see if you can get info out of your logs to help. |
40 |
|
41 |
hth, |
42 |
-- |
43 |
Iain Buchanan <iaindb at netspace dot net dot au> |
44 |
|
45 |
I tripped over a hole that was sticking up out of the ground. |
46 |
|
47 |
-- |
48 |
gentoo-user@l.g.o mailing list |