bash – Regex to replace the path that returns incorrect results

I must be missing something obvious, but I tried to do this in bash:

dfile="./_data/stuff/file.txt"; echo "${dfile///[^/]+///../}";

This gave the result ./_data/stuff/file.txt However, I expected ./../../file.txt. Can anyone tell me what I did wrong?


I also tried this, which also produced the same problem

dfile="./_data/stuff/file.txt"; echo $dfile | sed "s//[^/]+///..//";

python – Regex: match a variable array of elements discarding optional text

I need to divide some strings into a very large array where the strings have the form:

example = (
    "IV - Some text",
    "A) Some other text",
    "17-ter) an article",
    "2), 3) some ugly grouping",

I have this code:

import re
s = "b), c) molto altro testo per l'estrattore"
re.match("(?:((dw-)+)(), -))*(.*)", s).groups()

The code above indicates:

('b', ", c) molto altro testo per l'estrattore")

my expected result, however, is ('b', 'c', 'molto altro testo per l'estrattore').

Windows 10 – Regex: replace the content of one label with the content of another label

I have these tags and I want to replace the content of one tag (link one) with the content of another tag (link two). So to extract the content of one tag and replace it in another tag. For example

The output should be:

I made a regular expression, that works, but only if I change the order of the line, second line in front of the first line. I do not know why …

Search for:


Switch for:


regex – How to roll back newline characters in Notepad ++

I have a file with the following format


I want to find the symbol & # 39; | & # 39; (pipe) in a new line and replace it with recoil

To find this, my regular expression is as follows


It is working perfectly, but I cannot replace it with backspace at the end of the previous line as shown below.


And second case only for text


For this, the desired result is


Please suggest me how it can be possible.

htaccess: can I use REGEX for 301 a URL with additional characters at the end?

I just set up PHPlist to manage my email subscribers.

When people subscribe, they are taken to this page:

I would like to redirect them to a custom page here:

I tried 301 from / lists /? P = subscribe & id = 1 a / welcome, but this will not work. I guess this is due to the characters after / lists /.

And, I can't 301 from / lists to / welcome because / lists is the first part of the page to unsubscribe too.

Is there any way I can 301 from the previous full address with REGEX? Or is there another way to get people to a personalized page, without editing the PHP code base?

Thank you!

NGINX Location Wildcard / Regex does not work

I have tried countless combinations of wildcards / regular expressions in vain for the following code. Basically I just want you to capture any subdirectory of the /protected/ binder. If I use the following code for a specific folder, it works, but if I try things like location ^~ /protected/*/or location ^~ /protected/(a-zA-Z0-9)+/ breaks…

Any suggestions?

location ^~ /protected/sub-folder-01/ {
    if ($cookie_amember_nr !~* (a-zA-Z0-9)+) { #not authorized
        rewrite ^(.*)$ /members/protect/new-rewrite?f=5&url=$request_uri?$args redirect;
    set $file $document_root/members/data/new-rewrite/$cookie_amember_nr-5;
    if (!-f $file) { #have not access
        rewrite ^(.*)$ /members/no-access/folder/id/5?url=$request_uri?$args redirect;
    #everything is ok

Thank you!

regex – Optimizing a bash script

I have a bash script that looks for updates for Gentoo.

#! /bin/bash    
emerge --sync &> /dev/null
echo "$(emerge --pretend   -avuDN --with-bdeps y world | grep "Total" | awk '{print $2}' | tail -1)"

I don't want to have any way out in the stderr Y stdout transmission, so when I run this script, I have to redirect its output to a log file and then read the end of the file to print the expected number of updates. This is the command I invoke.

./ &> log  && tail -1 log

Is there any way to achieve the same without using an intermediate permanent log file? Can I use a temporary file? If so, how?

And in general, how can I improve this script?

regex – How to extract time out of text in Google Sheets

Here is a way to extract the date:

=split(REGEXREPLACE(A1,"(.)?D+|(../../....)|(0-9)","$2 ")," ",false,true)

A1 it is SomeText 02/02/2020 9:00 AM-02/02/2020 9:15 AM;"Text" 02/02/2020 10:45 AM-02/02/2020 11:15 AM;"Text" 02/02/2020 12:45 PM-02/02/2020 1:00 PM;

The output is

02/02/2020  | 02/02/2020    | 02/02/2020    | 02/02/2020    | 02/02/2020    | 02/02/2020

Regex command to replace in DB

Hello guys

I have been here for over a decade as a reader. I guess I'm finally perplexed and need help.

So, I have had a vbulletin forum for 17 years and now I imported it to Xenforo. Everything was good.

The problem is; I have 1.5 thousand posts and 22k of them contain links from different places in the forum.

Basically, see links here when someone in the past hit a link directing something to find something.

If someone reads the old posts and clicks on a link, they will go to page 404 not found.

These links must be edited in Xenforo format


Old Vbulletin4

New Xenforo2

If only I could somehow remove the thread tag on the old vb4 links


Then, after that, I can simply use a simple SQL update query to fix the rest.

So, I have 22k links in the posts table, all with different ID # and different tags.

Each tag starts with a script –

If someone is kind enough to help me, write me a regular expression or a complex sql command that removes all the final tags that come after the thread ID.

Both thread identification and tags will be different from one link to another, of course.

The only consistency is the hyphen, before the tag and the backslash after the tag. The backslash is only seen in the data table.

Here is an exact copy of the previous sample link copied from the sql table, the final backslash can be useful



Centos7 / mysql57

db table: xf_post
db index: message

Thanks to anyone who helps

RegEx optional value

I have the following RegEx written to force a phone number to be entered in the following format:


((0-9) {3} ) (0-9) {3} – (0-9) {4}

How do I do this so they can enter that exact format OR not enter anything?