How can I trim a string starting with a specific expression? [closed] - regex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How do I find and delete the utm_content parameter from all the urls in a file using Notepad++?
Sample data:
http://example.com/content1.html?utm_content=product1
http://example.com/abc2.html?utm_content=homepage
http://example.com/test/?utm_content=sku1234
http://example.com/runapp?utm_content=31231KS
http://example.com/blabla?utm_content=nl-laptops-tablets
Desired result:
http://example.com/content1.html
http://example.com/abc2.html
http://example.com/test/
http://example.com/runapp
http://example.com/blabla
Note: As I understand Notepad++ regular expressions use the standard PCRE (Perl) syntax.

As far as I understand your needs:
search for:
\?utm_content=.*?"
and replace with "

Search for \?utm_content=\w+ or \?utm_content=.* and replace it with a zero string if this is the only one parameter.

Use standard Search & Replace (Ctrl + R)
Edit:
Search: utm_content
Replace:
Press find and then press Replace Rest.

Related

Replace number with double quotes from csv file using vi editor [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have a CSV file containing the data like below -
"Rank","Domain","Open Page Rank"
"1","fonts.googleapis.com","10.00"
"2","facebook.com","10.00"
"3","twitter.com","10.00"
"4","google.com","10.00"
"5","youtube.com","10.00"
"6","instagram.com","10.00"
"7","s.w.org","10.00"
"8","ajax.googleapis.com","10.00"
"9","linkedin.com","10.00"
How can I remove double quotes from all numbers here using vi editor or similar effect?
Thanks
you could use a regex search and replace:
%s/"\(\d\+\(\.\d\+\)\?\)"/\1/g
"on every line in the file, find...
all strings that start with a double quote...
followed by one or more digits...
optionally, followed by a period, which is followed by one or more digits...
followed by a double quote...
replace the string with the outer capture group...
and do it everywhere it appears on the line.
"

how to remove string before second ":" in notepad++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I want to get last two strings email#email.com:namesurname from those strings. I know how to remove the last item after : with :.* but how can i do that for first also for those below? Just give me a recommendation if anyone can.
jobapplication:::2017-05-29:email#email.com:namesurname
also like this one:
skills:email#email.com:namesurname
I dont have idea to start it and there are around 3200 job applications.
Use the regular expression ^.+\:(?=\w+\#) to find unwanted string then replace all matches by empty string.
Have you considered recording a quick macro in which you do it once, replace or whatever, then press home home and down arrow to advance to the next line? Then you could do Run For Rest of File and it'd be done. (Make a backup first. ;)) I find the quick macro feature of Notepad++ comes in handy for this kind of thing, and easier (for some of us) to remember how to use than arcane regexes.

Rename a set of files based on regular expression [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am looking to rename a large number of files that look like this on my ubuntu box:
MattTest Season 01 Episode 02 - Episode Name.mkv
Would like them to look like this:
MattTest S01E02 - Episode Name.mkv
Thanks
You could try the below rename command. \K keep up the previously matched characters from printing at the final. That is, character which are matched before \K are won't taken into consideration.
rename 's/^\S+\s+\K(.)\S*\s+(\S+)\s+(.)\S*\s+(\S+)/$1$2$3$4/' *.mkv
OR
rename 's/^\S+\s+\K(.)\S*\s+(\d+)\s+(.)\S*\s+(\d+)/$1$2$3$4/' *.mkv
Regex Demo

Custom wildcard configuration in postfix [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Is it possible to use wildcards in the postfix virtual file?
Instead of allowing #mydomain.com I would like to know whether I can permit a specific configuration of an email address, for example I would like all these to be accepted:
xyzabcTRE456#mydomain.com
xyzabcFRS869#mydomain.com
xyzdefGLY643#mydomain.com
Could I have a single line regex-type entry in the postfix virtual table to cope with these permutations?
Thanks
Tim
You can use configuration parameter check_recipient_access in your smtpd_*_restrictions.
e.g, your main.cf should contains
smtpd_recipient_restrictions = other rule, other rule,..., check_recipient_access regexp:/etc/postfix/access.me,...
Then /etc/postfix/access.me should contains your regex. This page and this page should help you.
/^xyzabc/ OK

Notepad++ regular expression [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
{\i that}
and,
{\i it is this}
I cannot find the way to delete extra stuff from expressions so as to keep only at the above example the words "that" and "it is this".
Can you help me with the regular expression needed?
Try each of the following two expressions (the first one is more efficient if the text between { and } can't contain a } symbol):
\{\\i ([^}]+)\}
Or,
\{\\i (.+?)\}
and in both cases replace with \1.
echo "{\i it is this}" | sed 's/{\\i //;s/}//'
Search : \{\\i (.+)\}
Replace with : \1