IntelliJ IDEA How to bind regex replace to some key? - intellij-idea

IDEA have function for find and replace text in file (Ctrl + R) and supports regular expressions.
For example I write replace 1 to 2 and after this I need do it again, but I don't want write every time to fields what I want to replace.
Can I save it in list like live templates or bind on some key?

Related

pycharm(any IntelliJ product), how to add certain partern to the regex search result

I find what I want by using regex search, let's say I find all the telphone numbers in my file using regex and then I want to add a string "(+1)" in front of the results I found. What should I put in the "replace" input?
Is this possible? I searched a lot but all I found is that how to use regex and replace the whole stuff.

Google Colab notebook Find and Replace (Ctrl + H) using reg exp. Do capture group backreferences work on replace?

In the Google Colab notebook menu:
Edit :: Find and Replace (Ctrl + H).
Tick the "use regular expressions box".
The regexp queries work as expected on find.
However, in the replace box I am unable to enter any backreferences for capture groups.
The usual backreference syntax for capture groups is either \1 or $1 (e.g.for capture group 1)
However, this does not work in the replace box.
If capture group backreferences are supported on Colab notebooks then please would you explain the syntax and if possible give some examples.
COMPROMISE SOLUTION
I could not use the Edit :: Find and Replace (Ctrl + H) with use regular expressions box enabled to accomplish this. However, if you instead enable vim keybindings (Settings>Editor>Editor key bindings), you can accomplish this locally per cell.
While editing your cell of interest, press the colon key :, then use substitution command s/pattern/replacement/flag. Make sure you use \1 within the pattern and $1 within the replacement. This works for me on Colab to add comma to end of line: :s/(.*)/$1,. If I select multiple lines in vim Visual mode, then I can add a comma to the end of every selected line.
Reference

How can I make logical AND in intellij idea search

Sometimes I would find very useful to search (ctrl - shift - f) in intellij idea all files containing "string1" AND "string2".
Is this somehow possible?
Search for string1, then for string2 while using scope Files in Previous Search Result
You could use a regex search. Here's an example:
This regex: (?s)^(?=.*?string1)(?=.*?string2) matches any file that contains both strings, it doesn't care about order (i.e. which string comes first in a given file) nor does it care about the number of strings you search for so you can add additional criteria by appending another (?=.*?_your_text_here).
In addition, it can be easily extended to cover logical ORs ...
(?s)^(?=.*?string1)|(?=.*?string2)

Does mIRC Scripting have an escape character?

I'm trying to write a simple multi-line Alias that says several predefined strings of characters in mIRC. The problem is that the strings can contain:
{
}
|
which are all used in the scripting language to group sections of code/commands. So I was wondering if there was an escape character I could use.
In lack of that, is there a method, or alternative way to be able to "say" multiple lines of these strings, so that this:
alias test1 {
/msg # samplestring}contains_chars|
/msg # _that|break_continuity}{
}
Outputs this on typing /test1 on a channel:
<MyName> samplestring}contains_chars|
<MyName> _that|break_continuity}{
It doesn't have to use the /msg command specifically, either, as long as the output is the same.
So basically:
Is there an escape character of sorts I can use to differentiate code from a string in mIRC scripting?
Is there a way to tell a script to evaluate all characters in a string as a literal? Think " " quotes in languages like Java.
Is the above even possible using only mIRC scripting?
"In lack of that, is there a method, or alternative way to be able to "say" multiple lines of these strings, so that this:..."
I think you have to have to use msg # every time when you want to message a channel. Alterativelty you can use the /say command to message the active window.
Regarding the other 3 questions:
Yes, for example you can use $chr(123) instead of a {, $chr(125) instead of a } and $chr(124) instead of a | (pipe). For a full list of numbers you can go to http://www.atwebresults.com/ascii-codes.php?type=2. The code for a dot is 46 so $chr(46) will represent a dot.
I don't think there is any 'simple' way to do this. To print identifiers as plain text you have to add a ! after the $. For example '$!time' will return the plain text '$time' as $time will return the actual value of $time.
Yes.

Tool to format lines of text into array

I frequently come across this problem. I have a file:
something
something2
something3
which I want output as:
"something","something2","something3"
any quick tool for this, preferably online?
If its just a one off thing, it'd be pretty easy to just do it with a search & replace in any advanced-ish text editor...
For example in notepad++:
Do a Replace (CTRL+H)
Set "Search Mode" to "Extended"
Find: \r\n
Replace with: ","
(of course you'll need an extra quote at the very start & very end of the file).
If you need to do it more than once, writing a small script/program that did a regular expression replace over the file would be fairly straight forward too.
Edit: If you really wanted to do it online, you could use an online regular expression tester (in this case you want to use \n as the regex and "," as your replace pattern, leaving the other settings alone).
A quick Python hack?
lines = open('input.txt').xreadlines()
txt = ','.join(['"%s"' % x for x in lines])
open('output.txt', 'w').write(txt)