Questions tagged [regular-expressions]
108 questions
1
vote
2 answers
RegEx Match URL Pattern
I'm trying to come up with a regex pattern that will match any domains in this format:
example.com
but not this:
subdomain.example.com
Currently it needs to only cover the main TLDs (com, net, org), but I'd like it to be able to handle others (like…

MikeSmitty
- 27
- 1
- 9
1
vote
1 answer
Apache mod_proxy_html Substitute: how to re-use part of regex match? (regex variables?)
Have a unique URL-rewriting situation in Apache.
I need to be able to take a URL that starts with
"\u002f[X]"
or
'\u002f[X]"
Where X is the rest of some URL,
and substitute the text
"\u002fmeis2\u002f[X]
I'm not sure how the Regex works in…

SeanKilleen
- 1,083
- 8
- 25
- 38
1
vote
2 answers
PowerShell Regex for validating DOMAIN\username
I have the following regexp for validating Windows usernames in a PowerShell script.
$fqusername -imatch '^\w+[\\]\w+$'
This works fine in my own environment, but I am planning on releasing it for wider use, and want to make sure it validates…

dunxd
- 9,632
- 22
- 81
- 118
1
vote
1 answer
Firewall blocking files using Reg_Ex needs to be adjusted
We have security in our firewall to prevent SQL-Injection from destroying any of our content:
Name
Type
Context
Severity
Pattern
Configure
CS:select_into
signature
http-url
critical
.*\[select\].*\[into\].*
Edit
Remove
CS:select_from
…

Younes
- 135
- 5
0
votes
1 answer
Why my Fail2ban regex doesn't find matches?
I have tried many regular expressions in fail2ban config, but it never return any matches.
Line example:
[2019-12-10 10:45:38] NOTICE[15077] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '' failed for…
0
votes
1 answer
fail2ban filter for ical regex
i am trying to get a regex for an ical service on my host working without success. This is a part of the logfile:
Tue Jul 23 13:55:23 2019: ical|T720] [info ] Accepted connection from [::ffff:2.3.4.5]:56450
Tue Jul 23 13:55:23 2019:…

icey
- 3
- 2
0
votes
0 answers
Add rule in .htacces only if domain name begins with
I have to add a rule in a server that host many sites. This rule must be added only in those .htaccess files that belongs to a site with domain beggining with "dev-" or "review-".
I have…
0
votes
1 answer
Ansible replace. Replace part of the regular expresion
I create a playbook that will harden my linux servers. Part of the process is to replace the umask in the default profiles. So, I have created this task:
- name: Change the umask for default profiles
replace:
path: "{{ profile_file }}"
…

Peter
- 822
- 2
- 10
- 23
0
votes
3 answers
Logstash Grok Parsing Failed
I need to match this entry
2015/10/30 23:58:21 pid 22223 testuser@testserver.example.com 192.168.0.1 [p4/2012.2/LINUX26X86_64/536738] 'test-monitor show'
To match this I wrote this Regex
P4_DATE…

Prashant Lakhera
- 713
- 2
- 10
- 25
0
votes
2 answers
Regular expression for second and third domain level with hyphens
I have some smart script, that check name of server and get domain name. For example, i have name of server: example.ru01. I need to get: example.ru My scipt:
#!/bin/bash
hostname=example.com01
echo…

Piduna Valeriu
- 37
- 8
0
votes
2 answers
Doesn't work regular expression for domain with hyphens
I have some smart script, that check name of server and get domain name.
For example, i have name of server: example.ru01. I need to get: example.ru
My scipt:
#!/bin/bash
hostname=example.com01
echo…

Piduna Valeriu
- 37
- 8
0
votes
1 answer
nginx location regex not working
I'm trying to setup location directive to match my request but can't get it working.
Below is my sample request:
/APP/public/api/v1/item/100/type
location ~* ^/APP/public/api/v1/item/(.*)/type {
try_files /APP/data/type/$1.json…

davidcoder
- 101
0
votes
1 answer
regular expression to match condition of character if exists should always be followed by a pattern
I need a regular expression with the condition that ..if there is an occurrence of character | one time ;the pattern immediately following is ARGS or URL
For example
abcd
ab|ARGS
cd|URL
etc is valid
abcd|
ab||ARGS
ab|cd
etc are invalid (should not…

Anoop P Alias
- 347
- 4
- 7
0
votes
2 answers
How to escape pipeline char in Windows shell?
I need to specify a regular expression that includes | character to findstr command:
processtext.exe | findstr /R "Hello|Bye"
How do I escape it? \| does not work. Quotes fix issue with pipelining but the regex does not match although separate…

UserControl
- 135
- 1
- 6
0
votes
1 answer
Manage several sub domains with nginx
I like to handle different sub domains in my Nginx server, this is my config file (partially)
server {
listen 80 default_server;
listen 443 default_server ssl;
include …

DomingoSL
- 365
- 1
- 4
- 13