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.
Related
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
This question already has answers here:
Notepad++ v4.2.2. regular expressions to match and replace all text between two tags
(2 answers)
Closed 3 years ago.
I need a regular expression to replace the value in XML tags. I need to find * and replace it with XXXXX. I made an attempt to do this but its giving me "invalid regex".
<TAG>\('(.*?'\)</TAG>
// replace with:
<TAG>XXXXX</TAG>
I suspect that your actual starting content is something like this:
<TAG>some content here</TAG>
If you want to mask the content of such tags, you may try the following find and replace, in regex mode:
Find: <TAG>(.*?)</TAG>
Replace: <TAG>XXXXX</TAG>
Demo
Note that in general it is not desirable to manipulate nested content like XML/HTML using regex. But sometimes, e.g. when using tools like NPP, we are forced to do this. My answer should work fine assuming you are only targeting <TAG> elements which have no other children tags inside of them.
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.
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
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.