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.

learn more… | top users | synonyms (1)

3
votes
1answer
560 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
120 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
214 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
187 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
187 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
55 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
413 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
48 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
2k 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
193 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
997 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
148 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))$ ...
1
vote
1answer
1k 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
91 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
167 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
205 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
127 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
55 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
2k 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
126 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
228 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
342 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 ...
1
vote
2answers
459 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
85 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 ...
2
votes
2answers
4k 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
278 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
828 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
2k 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
69 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 ...
-1
votes
3answers
2k 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
1answer
177 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
105 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
2answers
518 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
56 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
326 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
483 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
309 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
1k 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 ...
2
votes
1answer
1k views

nginx: [emerg] unknown “script_filename” variable

I'm receving this error when trying to use script_filename nginx: [emerg] unknown "script_filename" variable nginx: configuration file /etc/nginx/nginx.conf test failed However script_filename is ...
1
vote
1answer
563 views

Convert from apache rewrite to nginx

I want to convert from apache rewrite modules to nginx RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] RewriteCond ...
1
vote
1answer
548 views

Question Mark ? Regex exchange transport rule

I'm trying to use the following Regex in exchange 2010 transport rules. Edit: Apologies - I wasn't very clear. I'm trying to match the question mark. I have escaped the question mark but still tells ...
0
votes
2answers
399 views

lighttpd redirect certain links to certain urls

Could someone tell me how / why is this redirect not working? $HTTP["host"] =~ ".*\\.mydomain\\.com" { url.redirect = ( "/index\.php\?pg=mysql" => ...
4
votes
1answer
490 views

Is it possible to get the matched regex from within the apache LocationMatch directive?

I'm wondering if the following code should be working: <LocationMatch "/(.*)([/])?(.*)"> Order allow,deny Allow from all AuthType Basic AuthName "Git" AuthUserFile ...
18
votes
1answer
455 views

Why bracket a single letter in a grep regex?

I've seen several instances where people are doing this: grep [f]oobar But I don't understand why that is preferable to grep foobar
1
vote
2answers
446 views

Extract repository name from GitHub url in bash

Given ANY GitHub repository url string like: git://github.com/some-user/my-repo.git or git@github.com:some-user/my-repo.git or https://github.com/some-user/my-repo.git What is the best way in ...
0
votes
1answer
671 views

Nginx alias and regex

i'll need a bit of help for alias on folder with nginx I have my folder www/ with the container of my site example.com and a lot of folder like client0, client1, client2... I should NOT modify ...
1
vote
1answer
455 views

trouble with location regex and redirection in nginx

I want to setup proxy in nginx: location ~ ^/m/([^/]*)/([^/]*)/([^/]*)$ { proxy_pass http://127.0.0.1:8080/redir/m/$1/$2/$3; proxy_redirect off; proxy_set_header Host $host; proxy_set_header ...
2
votes
1answer
225 views

encapsulate text in quotes with sed buffer

I need to do a search and replace to encapsulate a variable string in single-quotes (php object notation into php array notation) such that the following block: $my_trip->trip_id = ( ...
2
votes
1answer
401 views

Regexp in HAProxy's reqrep for asset management

I'm hosting assets on S3 with this kind of URL: http://cdn.site.com/image.jpg In my application I automatically serve versioned URL to force browser to download new files after the deployment: ...
0
votes
2answers
342 views

Need custom Nginx regex

Following is what I have right now and it works but needs some improvement. I am guessing that I will need to use regex and that is why I need help. What I need is this ...