Write regex on Notepad++ - regex

Zoom src/main/java/com/directv/acm/utils 80,9%
Zoom src/main/java/com/directv/acm/restclient/impl 81,0%
Hi guys, I'm trying to remove everything except numbers in my document. It's a ton of lines like this. Can anyone please write a regex for me in order to just keep the number only? Please.I hope that the result after modifying look like this (delete everything except the numbers):
80.9
81.0
My great thank to you!

Type CTRL + H for replace then ^.*(?=\d{2},) on the search field. Enable the Regular expression checkbox on the Search Mode and press the Replace All button

Try this:
Ctrl+ H to bring up the Replace dialog
In Find what, enter: [a-zA-Z /\%]*
In Replace with, enter: \n or leave it blank
Check: Regular expression option at the end
Click replace all

Related

Atom Editor: RegEx replace to uppercase/lowercase

I'm trying to replace some characters in a string with their uppercase/lowercase equivalents in Atom Editor.
Let’s say I have the string:
some:test:sequence
and want the result:
Some:Test:Sequence
I’m aware of things like \u$1 and \l$1, but they do not work in Atom, as Atom is using JS-style RegEx. The JS-RegEx solutions I found, however, always involve calling a function (see example here), which is not possible in Atom, afaik.
Does anyone know if there is a way to achieve this? I also don’t mind installing a package for a more powerful regex search/replace, but haven’t found one and I’d like to avoid writing one on my own just for this.
Please note: I’m not looking for a solution to find/select the characters. The selection works just fine and is a bit more complex as in the example.
Note that whilst you said the question is not about the selection, I'm using a more simplified example.
If you have a string consisting of: This is a Mixed case String! I want every Letter to Start with A Capital.
You can use the Regex selector of \b\w to find the first characters of every word in the string. (Done by Cmd + F and clicking .* on the right hand menu for Regex search)
Now press Alt + Enter to select all of the found results, this should highlight all results of the Regex query. Following this, to make every first letter uppercase you can press Cmd + K -> Cmd + U, you can modify them however you want from here.
Boom! The string should now look like: This Is A Mixed Case String! I Want Every Letter To Start With A Capital.
I've been looking for an answer for this question for a while, here are my sources for the answer:
arturomp's answer on modifying text (docs included in answer)
johno's answer on how to select all results from a Regex search (Relevant pull request included in answer)
Press alt + enter to select all matches, next go to menu:
Edit --> Text --> Upper or Lower case
A straight-forward kind-of solution within the framework of plain Regex would be to do the replacement for each character separately. This is probably not practical (if you have to trigger each replacement manually), but it works.
Search for all lower-case 'a' at the beginning of each word, replace it by the upper-case 'A'. Then 'b' for 'B', ... until you have all characters relevant for your target language/character set.
For me, It worked with Regex selector of \s\w to find the first characters of every word in the string.
For Mac :
cmd + F -> \s\w -> click on .* -> option+enter -> cmd+K -> cmd+U

Regular Expression to Remove Subdomains from Domain List

I have a list of domains and subdomains stored in a .txt file (I'm using Windows XP).
The format of the domains is this:
somesite1.com
sub1.somesite1.com
sub2.somesite1.com
somesite2.com
sub1.somesite2.com
sub2.somesite2.com
somesite3.com
sub1.somesite3.com
sub2.somesite3.com
I use notepad++, and I need to use regular expressions
Anyway, I don't know what to put in the find & replace boxes so it can go through the contents of the file and leave me with only the root domains. If done properly, it would turn the above example list into this:
somesite1.com
somesite2.com
somesite3.com
Can somebody help me out?
Thank you in advance.
It's an old question, but the answers provided didn't work for me. You need a negative lookahead. The correct regex is:
^\w*\.(?!\w+\s*\n)
You can use:
Find what: [^\r\n]+\.[^.\r\n]+\.[^.\r\n]+[\r\n]+
Replace with: empty_string
with regular expression checked and dot match line-feed NOT checked
I suggest using the Mark tab of the Notepad++ Find dialogue. Enter the regular expression ^\w+\.\w+\.\w+$, make sure that Bookmark line is selected, then click Mark all. Next, use Menu => Search => Bookmark => Remove bookmarked lines. These will remove all entries having with three "words" separated by two dots. It will leave all other lines in place.
An alternative is to mark all lines matching the regular expression ^\w+\.\w+$ and use the Remove unmarked lines menu entry. This I do not recommend as it will remove all lines with an unexpected format as well as the lines for subdomains.
Another method would use the Replace tab of the Notepad++ Find dialogue. Enter the regular expression ^\w+\.\w+\.\w+\r\n in the Find what field, and leave the Replace with field empty. The \r\n part of this expression may need some adjustment to account for the line endings set on the file.

Different replace for the same word notepad++

I have these words: TOP and LOCK. I have 49 times this word but I would like to replace it with a different word a lot of times. For example, the first time with luc and the second times with pile.
I would like to make it automatically. I have the list of the replace words in a text file. I use Notepad++.
I have searched on many sites, but cannot find a good solution.
I don't have notepad ++ but can you highlight and right click there's an option to replace? or highlighting it then clicking format at the top and clicking replace and finally using Ctrl + F and replacing it that way? sorry if i could not help :)
try this:
tap ctrl + F
you can look at this pisture to get the picture:
http://im34.gulfup.com/Vkws5.jpg
Hope it help you
Highlight TOP
Press Search on top menu bar
Go to Replace
Under Find What, in Replace with field type what you want to replace it with
Then hit Replace All
You will then see the changes
I'm not very familiar with Notepad++ but I can do this with Sublime Text. I guess it doesn't hurt for you to try it out.
First, select all the words you want to replace with multiple cursor mode. Basically you can find TOP|LOCK with regular expressions, and hit Alt+Enter to convert the found words to multiple cursors.
Second, copy the words you want to replace and use the Text Pastry plugin to paste them in, one word at each cursor.
See here for a demo: http://imgur.com/a/KrBB8#0

How do I do a regex search and replace in sublime text 2?

I want to remove inline style from an html document in ST2.
I imagine my regex will be something like this
style=\"*\"
If that's wrong, it doesn't matter. I'm sure I'll figure out the expression I'll need.
What I haven't been able to figure out, is how to actually use a regex to find or to find and replace text in ST2. The docs say that it can be done. But I can't find the documentation for how to do it.
Simply open the Search+Replace function (via Ctrl-H or the menu bar) and check the first box on the left of it (the one with an '*' on it, or you can press Alt+R)
Then the search field will be used as a Regex, and you can use the found patterns using the usual $1, $2, $3 vars in the replace box
More info here
I had a similar task to perform, the regex I used in the manner that Nas62 suggested was
style=\"(.*?)\"
Find What : style=".*" Replace With : leave it as blank
Click Replace All button.

How to recall search pattern when writing replace regex pattern in Vim?

Here's the scenario: I've got a big file filled with all sorts of eclectic rubbish that I want to regex. I fiddle around and come up with a perfect search pattern by using the / command and seeing what it highlights.
Now I want to use that pattern to replace with. So, I start typing :%s/ and I cannot recall what the pattern was. Is there some magical keyboard command that will pull in my last search pattern here? If I'm writing a particularly complex regex, I have even opened up a new MacVim window, typed the regex from the first window into a buffer there, then typed it back into the Vim window when writing the replace pattern. There has got to be a better way of doing so.
Found my own answer after having written up the question: Vim tips lists it as substitute last search and can be done in one of two ways.
Using an empty search:
:%s//replace/g
By pressing Ctrl + r then / to recall the material from the search buffer (/ - you can use any other named buffer by substituting the / for the letter representing that buffer).
There is a / register that contains the current search pattern, so you can insert the search pattern into whatever you are typing (either in insert mode or on the command line) with <CTRL-R>/
Another option: after entering the pattern with <CTRL-R>/, edit the command line with <CTRL-F>.
:help cmdwin