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.
Questions tagged [regex]
720 questions
0
votes
3 answers
NGINX + RegEx redirect: http://sub3.sub2.sub1.domain ---> https://sub1.domain
How can I use regex and nginx together so that these will all redirect to the same endpoint?
http:// sub1.example.com
http:// sub2.sub1.example.com
http:// sub3.sub2.sub1.example.com
https:// sub1.example.com
https:// sub2.sub1.example.com
https://…

cashsavings
- 1
- 1
0
votes
1 answer
Script to find sequences of lowercase letters joined with underscore or dash
I am newbie in writing scripts in powershell, and even more in regular expressions, please help with the implementation.
example:
PS > .\test.ps1 "A Balrog is a powerful fictional monster in Middle-earth."
return: Middle-earth
or
PS >.\test.ps1…
user612357
0
votes
1 answer
How to redirect old PHP scripts in NGINX configuration to a new HTTPS site?
I have a problem, I'm trying to catch all PHP scripts except one in my NGINX configuration for my HTTP domain configuration:
I have a general rule for all PHP files
location ~ \.php$ {
include fastcgi_params;
try_files $uri =404;
…
0
votes
1 answer
HAPROXY regsub match '?' questionmark
In HAproxy replacing the incoming url with some data.
This is the incoming path:
/powerbi?redirectSuccessUrl=/reports
I want to match:
/powerbi?
replace it with
clientId=${clientId}&
And final outcome must…

Ashwin R
- 103
- 4
0
votes
1 answer
nginx reverse proxy and regexp location
here is what I want:
uri like: http://mydomain.xxx:33380/client001 should be redirected to http://10.8.51.21:3780/ui in VPN.
uri like: http://mydomain.xxx:33380/client001/adm should be redirected to http://10.8.51.21:3780 in VPN.
My config here:
map…
0
votes
1 answer
How to remove text after a 4 digit year in a file name
I am looking to remove all text after the 4 digit year of movie files:
Input:
Some.Movie.Name.2011.1080p.BluRay.x265.mp4
Another.Movie.Name.1999.1080p.BluRay.x264.mp4
Another.Movie.Name.II.2001.1080p.BluRay.x264.mp4
Desired…

Brian Kuepper
- 39
- 4
0
votes
1 answer
Parsing mail logs
Below is a link to an extract from my Postfix server's mail log, showing one successful SMTP transaction. Is it possible to configure Postfix to add a unique ID tag to all log entries involving the same transaction, from start to finish? Similar to…

Julian
- 1
- 3
0
votes
1 answer
how to parse some mails from html code
I want to build a little bash script to detect some mails in a HTML-code.
currently, I am not sure how can I build the right regex to auto-detect emails from HTML.
I tried this regex with curl:
egrep -o "\S*@.*\.\S*"
But this includes all…

cyno
- 3
- 1
0
votes
0 answers
Nginx match all paths except some
I'd like to create a rule to match all the paths except some.
site.com/
site.com/admin/
site.com/user1/
site.com/user2/
site.com/user3/
Here's what I have so far but looks like something wrong.
location / {
# configuration for…

ozgrozer
- 101
- 3
0
votes
1 answer
Fail2ban not finding or banning IPs
Fail2ban version v0.10.2
I have a simple jail that looks for a specific user agent.
[barkrowler]
enabled = true
filter = barkrowler
logpath = /var/log/apache2/proxy.mydomain.com.access.log
port = 80,81,8103,8203,8303
maxretry = 1
findtime =…

DevOpsSauce
- 348
- 1
- 5
- 22
0
votes
1 answer
Preventing directory traversal in nginx ingress in Kubernetes
I have the following ingress defined:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: someName
namespace: test
annotations:
kubernetes.io/ingress.class: "ingress-public"
nginx.ingress.kubernetes.io/affinity: "cookie"
…

Farhan.K
- 63
- 7
0
votes
1 answer
NGINX: redirect url to custom port with reverse proxy
I am tunneling some remote cameras throw SSH to a VPS. I want to be able to pass the port number over the url, and nginx proxy it to the localhost:'that port'.
Pretty much this:
http://test.doman.com/1234/ -> localhost:1234/something/
I found a…

IamRichter
- 1
- 1
- 3
0
votes
1 answer
Subdomain instead of a Subfolder with Apache Reverse Proxy?
The Lounge gives an example to use a reverse proxy with Apache.
RewriteEngine On
RewriteRule ^/irc$ /irc/ [R]
RewriteCond %{REQUEST_URI} ^/irc/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /irc/(.*) …
0
votes
1 answer
Redirect http to https but different port in IIS 8.5 for my .net core application
I have my .net core application. The http site is http://www.myfakesite.com:5000 But my https site is https://www.myfakesite.com:5001.
What I want is when I open the http site it will be re-directed to https site.
You see the port is also changed…

Hello
- 101
- 1
0
votes
0 answers
Nginx captured regex can't be reused later for includes?
I capture the server name like this:
server_name ~^(?.+)\.myapp\.io$;
an later i try to use it on the same file, like:
include $account.conf;
but it returns:
nginx: [emerg] open() "/etc/nginx/$account.conf" failed (2: No such file or…

CrazyRabbit
- 439
- 4
- 13