When asking regex questions, always add the tag for the specific programming language or tool (e.g., Perl, Python, or Java; vi, emacs, or ɢɴᴜ grep; etc.) you are using.
0
votes
0answers
5 views
how to pattern matching on mulit line string? [migrated]
mystring = "
<div class="text">
Spor
</div>
";
pattern ="<div class=\"text\">(.*)</div>";
Pattern regEx = Pattern.compile(pattern, Pattern.MULTILINE);
Matcher m = ...
0
votes
1answer
27 views
Extracting matches in NGiNX with regex without if block
With NGiNX I get a string that contains information that I can extract content with regex.
But the only way I found that I could do this, is with if block. Is there any another way?
The extracted ...
1
vote
1answer
67 views
Nginx - Redirect request by GET parameters pattern
One of my servers was attacked by DDoS a couple of days ago and it lasted for 4 days. Below are the logs snippet of the request:
36.224.180.253 - - [14/May/2013:03:11:46 +0800] "GET ...
0
votes
0answers
21 views
Coloring multitail alternative that scrolls using the terminal client? [closed]
multitail is great tool as it can be configured to highlight specific strings but because it is a TUI application you lose the ability to scroll using your terminal.
You have to press b and use the ...
1
vote
1answer
15 views
Nginx 404 rewrite issue
I'm trying to grab variables between slashes and pass them to my management script with the following rewrite line in Nginx:
rewrite ^/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ ...
0
votes
2answers
32 views
How can I replace an apostrophe in a URL using htaccess?
I have a website with a search box on it. The search term is passed to the search page as part of the $_GET (I'm using PHP, but I think that's irrelevant to the problem I'm having), so my final url ...
0
votes
2answers
35 views
nginx simple regex location
I need to set a location param in nginx if the first 5 digits of the url are numbers.
site.com/12345/ or site.com/12345
But I can't for the life of me seem to get the correct regular expression.
...
1
vote
1answer
62 views
How to block all incoming proxy visits except from one specific I.P?
I have a page that is prone to attacks, so, in order to reduce the anonymous attacks, I use this code in my .htaccess which I found online :
# BLOCK PROXY VISITS
<IfModule mod_rewrite.c>
...
0
votes
1answer
45 views
Change default document root for all subdomains in directadmin
is there any way to set document root for all subdomains to a different path like: (www/path/subdomains) using regexps or something else?
something like this?
|*if SUB="*"|
...
1
vote
1answer
68 views
How do I use “catchall” in my postfix alias?
I have this in my main.cnf:
alias_maps= regexp:/etc/aliases
Inside that file, I have:
/^reply*$/: jjj
Now, when I send it to reply-124233@mydomain.com, postfix bounces it because
Recipient ...
1
vote
2answers
57 views
The meaning of * in Basic regex versus Extended regex
I thought * meant zero or more of the character or class that precedes it in basic or extended regex. Why does echo hello| grep '*llo' fail but echo hello |egrep '*llo' succeed?
0
votes
4answers
64 views
Move files to subdirectories: /img/ab123.jpg --> /img/ab/ab123.jpg
I have a linux webserver with about 25.000 images in one directory. They are all lowercase and in the format two letters, three digits and jpg as the extension. Because that many files in one folder ...
-1
votes
1answer
87 views
Some regex for powershell [closed]
I have below sample file(s).
Symmetrix logical device count=13
CLARiiON logical device count=0
Invista logical device count=0
Generic logical device count=0
...
0
votes
0answers
69 views
Multi-line regex replacement in apache
I need to do multi-line replacement in apache2, an mod-substitute only does single line matching AFAIK.
I need to be able to do something like this:
replace
<script>
foo = x;
bar = y;
alert(x ...
0
votes
1answer
32 views
nginx rewrite and Drupal
My web root is in /staging/ and I'm currently using this rewrite line:
location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
...
0
votes
1answer
112 views
How to have nginx serve only the home page of site?
I am running a server with nginx on port 80 and Apache on 8080. I want the home page of my site to be served with nginx, and every other request passed through to Apache. I found this great article ...
1
vote
2answers
36 views
Perl regex expression
I have the following string produced by a server log file. I am using Simple Event Correlator (which uses perl regex) to manipulate lines:
18:37:31 643.65.123.123 []sent ...
2
votes
2answers
178 views
Nagios check_http - checking tomcat application status with regex & linespan
I wan't to check with our Nagios if a webapplication is running on Tomca7. I decided to use the check_http plugin with regex. I'm parsing the status-page of tomcat and check if column "Running" is ...
0
votes
1answer
92 views
Debian, Search and replace iframe injection [duplicate]
We're running a Debian server and we have a malware or something doing code injection.
I know how to search and replace this string :
<iframe src="http://ingvar2000.no-ip.org/jc/rss.php" ...
0
votes
1answer
92 views
nginx httpMapModule regex variables
The HttpMapModule documentation states that:
Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*.
And gives the example:
map $uri $myvalue {
/aa ...
0
votes
1answer
57 views
Nginx Config File Regex Issue
I am trying to convert the following rewrite rule into a 'try_files':
location ~* \.(css|js) {
if (!-f $request_filename) {
rewrite ^/wp-content/w3tc/min/(.+\.(css|js))$ ...
0
votes
1answer
117 views
pcregrep is not matching regex (multiline?)
I don't understand why is first two is a match/hit, yet third is a miss?
-bash-3.2# cat 1361492805.M171838P41834.mx1.alexus.biz\,S\=12921\:2\,Sijm | pcregrep -q '.*languager.*' ; echo $?
0
-bash-3.2# ...
1
vote
0answers
53 views
PHP UTF-8 bondary regex does not work
I have a CentOS 6 with newest updates running a LAMP stack.
A user is complaining that his code does not work and he is trying to use preg_match with unicode characters.
This is the code not ...
0
votes
1answer
71 views
.htaccess rewrite: how to remove all directories but the first and second?
I'm trying to get a specific .htaccess rewrite done, but my regex skills are limiting me to do so;
example 1: www.domain.com/dir1/dir2/dir3/file.txt should become www.domain.com/dir1/dir2/file.txt
...
0
votes
2answers
48 views
Lighttpd vhost regex
I'm having a problem with my vhosts using regex. When I use the following code, I get a 404 not found:
$HTTP["host"] =~ "(^|\.)example\.com$" {
...
}
However, when I explicitly set it to the ...
1
vote
2answers
52 views
Grabbing the directory path in a message like “You have new mail in /var/spool/mail/root”
So I often get messages such as You have new mail in /var/spool/mail/root and end up typing/copy-pasting out: tail /var/spool/mail/root, which is a bit cumbersome.
Is there a simple command that ...
1
vote
1answer
32 views
Mod_Rewrite Rule (or an Alternative) For Reorganizing Directory Structure [closed]
The website I work on had these two pages in the past:
http://www.africananimals.com/stripes/zebras
and
http://www.africananimals.com/news/zebras
(These are not actual domain names, just ...
1
vote
1answer
156 views
replacing a line or date in a text file using powershell
I am trying insert today's date on a text file at line 59. How do i do this?
Line 59 has like 30 spaces and then reads like this. After the PowerShell script runs it will change the date so it has to ...
0
votes
1answer
35 views
Samba share content filtered based on regex rules
I would like to create a Samba share that filters the contents of a directory based on a series of regular expression matches against file names. For example, I would like the share to allow access to ...
0
votes
1answer
85 views
Regex matching specific details if first match exists, multiline
I'm struggling to get the correct regex to match specifically 'Contact' and 'User-Agent' only if the 'Contact' address matches 10.0.x.x in ~70GB of SIP messages.
The SIP message will always contain a ...
0
votes
1answer
92 views
Matching req.http.Host in Varnish via Regex vs Standard Operators
I am able to do either of the following:
Host match using standard operators:
if (req.http.Host == "domain1.com" || req.http.Host == "domain2.com") { ... }
Host match via regex:
if (req.http.Host ...
0
votes
2answers
70 views
centos - how to find a filename with all the possible extensions?
I need to perform a search for "foo" and return all the filenames/ directories with this name (e.g. foo.php, foo.txt etc ). It should run through the whole filesystem and find even hidden files .
...
0
votes
1answer
54 views
Htaccess regex working strange
I am trying to write .htacess file that would catch urls like:
http://www.site.com/pageone.html
http://www.site.com/pagetwo.html
and redirect them to index.php so it would receive 'pageone' and ...
0
votes
0answers
82 views
Practical Nginx configuration based on user agent
Could you please suggest some practical nginx configuration relying on $http_user_agent to rewrite/proxy differently in these scenarios:
All modern client browsers - I would render all html on the ...
1
vote
2answers
310 views
Using sed to remove both an opening and closing square bracket around a string
I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time.
I know square ...
-2
votes
2answers
107 views
NTP server hostname validation regex [closed]
I want make basic syntax validation of NTP server hostnames. (For example, I expect %^$&" is a syntaxticly invalid NTP server hostname.)
The reason I want to make this basic validation is because ...
-3
votes
1answer
123 views
Apache FilesMatch directive - “Multiple arguments not (yet) supported”
What the heck... There's only one argument, the regex.
Earlier in the file, I denied all.
Now I just want to allow access to index.php, as well as images, css, and javascript.
<FilesMatch ~ ...
0
votes
1answer
284 views
postfix header_checks using regexp proper setup
I just can't seem to figure out why header_checks are not being evaluated.
I'm on Ubuntu 12.04, postfix 2.7, dovecote, spamassasin, clamav, amavis.
I add following line to /etc/postfix/main.cf :
...
-1
votes
3answers
57 views
perl remove two slashes regex [closed]
I have file wich has many lines inside
All lines that contain
file=/aaaaaaa/bbbbbbb/cccccc/dddddd.txt
it needs to be stripped to this format
file=/dddddd.txt
i am executing perl in bash ...
-2
votes
3answers
608 views
Trouble Letting Users Get to Certain Sites through Squid Proxy [closed]
We have Squid running on a RHEL server. We want to block users from getting to Facebook, other than a couple specific sites, like our organization's page. Unfortunately, I can't get those specific ...
0
votes
0answers
26 views
How to use .htaccess to force “www.” in front of any domain, except when testing locally on “localhost” [duplicate]
Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?
Uisng .htaccess' RewriteCond, and RewriteRule, how can I do the following:
If ...
0
votes
0answers
36 views
Apache environmental variables in regular expressions
I use Apache environmental variables with path declarations. E.g.:
<Directory ${VHOST_PATH_DOCUMENT}/www.mydomain.com/htdocs/images/>
Can these be used within regular expressions? Something ...
0
votes
1answer
75 views
Unexpected varnish behaviour of regsub
According to the varnish documentation, the regsub method should not result in a 301 redirect. Yet that is what seems to be happening in my case (that is, the url actually changes in the browser).
...
-1
votes
3answers
81 views
Rename tons of files
How can I rename all the files with a pattern like this:
thumb_f318d8a580ca5717d686a323b6c2ca0d.jpg0000777
thumb_f18d8aup90ca5717d686a323b6c2c5uh.jpg0000777
...
0
votes
1answer
177 views
Nginx RegEx to match a directory and file
I'm wondering if it's possible to match Wordpress directory and specific file in the same location, so at the moment I've got rule to match only the wp-admin directory:
## Restricted Access ...
0
votes
1answer
45 views
htaccess not properly rewriting urls
This is a bit of a weird one. I'm doing some work on a server, and I need rewrite rules for directories that actually exist (in some cases, they are more than one level deep)
At the moment my ...
1
vote
1answer
141 views
htaccess rewrite rules to match dynamic params
My base url looks like this.
http://localhost/test/s/beer-drinks
And depending on the users input it can be something like this.
...
1
vote
0answers
223 views
Squid Random Shared ip proxy
Running Squid with a acl random ip setup, Have 745 ip's in the pool and we are about 10 users that use it with tools that are running multiple threads, Check rankings on Google etc
Issue: We did ...
1
vote
1answer
137 views
Mechanism behind user forwarding in ScriptAliasMatch
I am following this tutorial to setup gitolite and at some point the following ScriptAliasMatch is used:
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
...
0
votes
2answers
407 views
How to combine RewriteRule of index.php and queries rewrite and avoid Server Error 404?
Both RewriteRule's works fine, except when used together.
1.Remove all queries except query ?callback=.*:
# /api?callback=foo has no rewrite
# /whatever?whatever=foo has 301 redirect ...
