How to use RegEx (in Notepad++) to remove unnecessary information? [duplicate] - regex

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 5 years ago.
I have opened a list of log files in Notepad++, and would like to use Regular Expressions to remove everything (on each line), which precedes the log file name itself (as attached).
If anybody can offer advice on how to go about removing the unnecessary information on each line (using RegEx) it would be greatly appreciated.
Kind Regards,
Davo
enter image description here

Try these steps:
Ctrl+h
in find type .*IN
In replace type IN
Select Regular Expression checkbox.
Click Replace All

In this case, you don't even need to get fancy with search replace, just use block selection and press delete. Block selection can be done like normal selection but hold down the ALT key

Related

Replacing a certain number of characters after a match in regular expression [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
I want to find any instance of
\/Network\/Cambric Corporate Center\/
and replace the next 8 characters with nothing.
So something like this
\/Network\/Cambric Corporate Center\/1164.DEV1164
Turns into this
\/Network\/Cambric Corporate Center\/1164
I'm working with a baked in replace regular expression visual programming piece, and this is my first post to here ever so please ask if more info is needed. I basically just need it to look like this
\/Network\/Cambric Corporate Center\/1164
if there is another solution without having to use replace
It is for a frequently updated mass source of data that I need to edit to make more compatible with arrays
Try (\/Network\/Cambric Corporate Center\/).{8} and replace with $1 to keep the first group but not anything else.
Here's the regex with the replacement: https://regex101.com/r/F4Y4VD/1

Notepad++ How to CUSTOM Regex this content [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 3 years ago.
I have below text:
_pranay_:pranay:104.144.219.145:3128
_ridhoo:rihdonk:104.144.224.242:3128
_shintna_10:shinhana:104.144.235.149:3128
_waled_jr_:ismail:104.144.241.222:3128
Which represent USER:PASS:PROXY
now I want to use a regular expression to remove the USER and PASS and keep the proxy.
Output like:
104.144.219.145:3128
104.144.224.242:3128
104.144.235.149:3128
104.144.241.222:3128
I've tried my best with failed attempts. am not that good in Regex. I wish somebody who can help me out. Thank you.
You can use https://regexr.com/ to play around with regex. For example, the expression below captures the part you want to remove:
([_a-zA-Z]+[0-9]*:)
Or, try the expression below to match the parts you want to keep;
([\d+\.]*:[0-9]{4})
As I'm no regex-expert, there might be better expressions available. But I recommend the link I provided to learn some regex.
You can maybe simply replace,
^[^:\r\n]*:[^:\r\n]*:
with an empty string.
Demo
If you wish to simplify/modify/explore the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.

Remove first char from string - Regex [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 4 years ago.
I have started using Workflow on iOS to help speed up tasks at work. One of those is entering delivery records into the computer (via the iPad barcode scan function) instead of manually writting down the ref code and then typing it in.
Workflow has a "Replace Text" function that can be used with regexs to strip out characters etc.
I have managed to find a regex to get rid of the last digit in a scan (a checksum digit, always a capital letter).
The regex is simple.
.{0}-$.
This goes in the "Find Text" field. The "Replace With" is left empty. It works wonderfully.
How can adapt this to work with other scan types with other scan types where I want to specically get rid of the FIRST character only? I've searched the forums but can only find long and difficult to interpret regexes that I am sure won't do what I am trying to achive, something simple by comparison.
An example is of what I mean is to convert "Y300006944" to "300006944"
You can use the following regex:
^.(.*)$
with a backreference $1 that you can use as replacement.
Good luck.
Thanks to those who contributed somehting useful :)
I got the it resolved by using the "Split Text" function in Workflow for iOS.
I gave it the command to split based on a customer char, "Y" in this case. It's enough in this simple case.

Capture everything after one word [duplicate]

This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 6 years ago.
I am trying to make a regular expression capture any words in the specific line after the word Attachment:
This question is for work, so it is not a homework or test question. I took the paragraph below as an example from www.regular-expressions.info. I did not major in computers but Psychology so this is completely foreign to me. I've read the manuals for the last two days, and because this is going over my head, I don't know how to begin.
I have a task which involves me linking the attachments to a specific file with the same name saved in a folder (at least 500 attachments) on Adobe PDF. What I did before was to manually select the words and link it to a specific file in a folder, but it is tedious to do when they can go up to 500 attachments.
I was aware of an application plug-in called EVERMAP that you can download for Adobe to automatically link specific words to a specific file in a folder. However, it requires me to use regular expressions which again, I don't know how to use.
I will bold the words I want to capture in the paragraph below.
The repetition operator manual expand the match as far as they, and only come back if they must to satisfy the remainder.
Attachment: The repetition operator manual
The asterisk or star tells the engine to attempt to match the preceding token zero or more times. The plus tells the engine to attempt to match the preceding token once or more.
Attachment: Asterisk and stars engine
Attachment: (.+) should work in your case unless there are other exceptions to this rule. The regex simply tells the parser to capture 1 or more character after the word Attachment:. See here for the sample
Like #Kevin said, the Regex is simple. Use Attachment: (.+).
Maybe you are confused on how to use Regex. I don't know about the Evermap plugin, but you can copy all the text from the PDF to Sublime Text (text editor to open .txt but with a lot of features) and do Regex part there. And then, since you are not a programmer, you should remove other irrelevant data. So the Regex will be:
`^\s*Attachment:\s*(.+)$|^(?!Attachment:).+$`
And replace it with:
`\1`
\1 is a variable containing group value caught in ()
In Sublime Text find Find and Replace, then apply the Regex there. Don't forget to turn on the Regex mode.

Regex to strip single comments and muti-line comments in Notepad++ [duplicate]

This question already has answers here:
How to match c-style block comments in Notepad++ with a regex?
(2 answers)
Closed 9 years ago.
the followings :
// comments
/******
comments
*******/
is it possible to have a regex for them ?
As the comments say, its not possible to strip comments in a correct way with regexes. But maybe its still enough for you to use the following regular expressions:
^\s*//.*$
/\*.*?\*/
You can do this with a simple hack. Select Extended mode and then replace all \r\n with a character/character-sequence that does not occur in your file and that which will match .*. Now change back to Regular Expression mode and apply the regular expression (given by morja) to do your replace. Now replace back the special character/character-sequence with \r\n.
#Mohammad Currently you cannot do this (match multiline) in Notepad++.
This is because matching newlines is possible in Extended search mode, and regular expressions are available in Regexp search mode.
You could however combine different steps and do what you want as pointed by other answers.
The easiest solution is not to use regex from Notepad++, you sould only export as rtf (plugins --> nppexport --> export to RTF) then open with Microsoft Word or other that support format searching, so with that feature you can search and replace the green values only.
I hope it helps.