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

0
votes
1answer
552 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
132 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 ...
1
vote
1answer
913 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
2answers
111 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 ...
0
votes
2answers
160 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
1answer
53 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 ...
0
votes
1answer
160 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 ...
1
vote
1answer
868 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
102 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
240 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
260 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
79 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
2k 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
201 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
634 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
1k 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 : ...
-2
votes
3answers
1k 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 ...
-1
votes
3answers
65 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 ...
0
votes
1answer
1k views

Apache htaccess RewriteRule to remove trailing slash; infinite loop?

I use the following in .htaccess (mod_rewrite) to remove the trailing slash from my URLs: RewriteRule ^([a-z0-9_-]+)/$ $1 [L,NC,R=301] Of course, since the character class doesn't match a slash, ...
6
votes
1answer
2k views

What are PCRE limits?

In ModSecurity there are PCRE limits exceeded errors. I know I can fix this by setting rules such as: SecPcreMatchLimit 150000 SecPcreMatchLimitRecursion 150000 But, what are these rules actually ...
0
votes
1answer
142 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
98 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
2k views

Make exception to whole-site RedirectMatch rule

We have this RedirectMatch rule to move clients on the SSL enabled site while maintaining the path they're trying to access: Redirectmatch permanent (.*) https://www.foobar.com$1 and it is working ...
1
vote
1answer
234 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. ...
0
votes
1answer
53 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 ...
3
votes
2answers
781 views

Replace Wildcard Character in Filenames

I can't get this to work: I have hundreds of files that our database developer has foolishly put asterisks in, so that we have files named like this: *1*_Floorplan.jpg I need to recursively (two ...
1
vote
0answers
384 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
2answers
1k views

Simple URI redirection / alias in Nginx

Please, how can I make this simple operation in Nginx: I wish that every requests for uris like: http://example.com/adm or: http://example.com/adm Goes to the wordpress login page: ...
0
votes
2answers
781 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 ...
1
vote
1answer
265 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
281 views

ModRewrite 9 Back Reference Limit

This is a complicated one which I hope has a simple answer... RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) category.php?c_id=$2&filters=$3&_p=$4&name=$1 This rule would pick ...
1
vote
2answers
287 views

Why do two patterns (/.*) and (.*) match different strings?

Shouldn't the two patterns (/.*) and (.*) match the same string? My real question is actually: where did the "abc" go? Something funky seems to be happening inside the mod_rewrite engine... Given ...
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
362 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
364 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
357 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
387 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
446 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
2
votes
1answer
341 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: ...
1
vote
2answers
325 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 ...
1
vote
1answer
306 views

What regular expression can I use to identify invalid file requests in nginx logs?

I need help configuring a regular expression for fail2ban. I use my web server primarily for simple podcast file hosting but I see a lot of invalid requests for php, asp, and pl files in the logs. ...
1
vote
1answer
377 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 ...
1
vote
0answers
49 views

Convert …/($var1|$var2)/… regex to string [closed]

In one part of my shell program I need to translate many of lines in the following pattern /(folder1|...|folderN)/(sub1|...|subN)/.../(file1|...|fileN) into strings : /folder1/sub1/.../file1 ...
2
votes
1answer
186 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 = ( ...
0
votes
2answers
306 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 ...
0
votes
1answer
96 views

Need nginx regex rewrite debuging help [duplicate]

Possible Duplicate: Need custom Nginx regex Desired outcome is this: http://www.example.com/about/?r=something to this: http://www.example.com/about.php/?r=something This is what I ...
0
votes
1answer
335 views

Modify swatch conf files to match multiple lines below a match

We use swatch for reading PHP logs and email them to us. Currently it emails one single line of the error, but fails to match the next few lines of stack trace. For example: for log file like this: ...
2
votes
1answer
221 views

htaccess email regex

I am trying to write a patter in such a way that this link : http://www.mysite.com/link/go/emailadress@gmail.com is interpreted like this : ...
-1
votes
2answers
272 views

Regular expressions to find SQL Errors in Logs

I am running a log parser to find SQL errors in my log files. If the search string (regular expression) is evaluated to true, the line will be marked. So far I used the search expression "SQL0", which ...
1
vote
1answer
423 views

Check if folders exist in Git repository… testing if a sub-string exists in bash with NULL as a separator

I have a common git "post-receive" script for several projects, and it needs to perform different actions if an /app/ or /public/ folder exists in the root. Using: FOLDERS=`git ls-tree -d ...