I just purchased PHPStorm and while writing and if statement i realized that PHPStorm wants me to write an if statement like this WITH braces: if($value == $value2){}; I want to use colon instead after the if statement is that possible like this. if($value1 == $value2): endif;
Ive tried several things to make it work... It just seems that they don't support colon after statements... I hope you clever guys has the answer... Thank you!
Related
been doing Go programming on Codewars as a hobby and stumbled upon following task:
The code provided is supposed to replace all the dots . in the specified String with dashes -
But it's not working properly.
Task: Fix the bug so we can all go home early.
Initial wrong code:
regexp.MustCompile(`.`).ReplaceAllString(str, "-")
Through brute force, i've made it work like this:
regexp.MustCompile(`[.]`).ReplaceAllString(str, "-")
The correct answer is apparently this:
regexp.MustCompile(`\.`).ReplaceAllString(str, "-")
Could someone please explain the logic behind my solution and the right one.
Thank you in advance!
Your solution is correct too.
In regex, the dot define a special metacharacter but inside a character class it's a regular dot.
It is possible however to complain about the misleading impression of metacharacter use, so the escaped dot is more clear and easy to understand.
I made this very simple regex
extract("ProductCode",0,message)
And of course it's working but I have no idea how to make it case-insensitive. I tried to add 'i' flag like this
extract("productcode/i",0,message)
or like this
extract("/productcode/i",0,message)
nothing works.. no idea what I'm doing wrong. Please help
You can try the following syntax:
(?i)productcode(?-i)
This will make that part of your regex case insensitive.
You can dismiss the (?-i) if you want to apply it to the whole regex.
Good luck.
I run a small forum that has an issue with people using parentheses to bracket statements. They do it to signify they are talking about Jews. I guess it is called echoes or something. So they will put a name like (((Prominent Person))) like that in the middle of a conversation.
I have recently been trying to combat this without just banning people that can't behave. I have a decent word filter but it doesn't block that. I recently installed something that allows me to use regex to strip things out but I am having trouble finding the proper string that doesn't break everything else.
"/\W{3}(.*)\W{3}/","$1"
The first is the matching string and the comma separates what is left. This string works, it strips the parentheses out and leaves everything else alone. The problem is that the string is too broad. It also strips out any [ brackets as well which breaks all of the bbcode in a post. Any post that has any number of at least 3 brackets will be broken after that.
I have been playing with different strings on regex101 but not finding the best solution. I need any time that ((( or ))) is seen to strip out those and replace it with nothing, like it never happened. It has to be exactly three and only ((( and not the other brackets it could trigger on.
Does anyone have a good solution?
\({3}(.*)\){3}
https://regex101.com/r/wD5TMb/1
So in your format probably: "/\({3}(.*)\){3}/","$1"
So I'm coding in VIM, and I ran into a strange problem. I closed out of my source code, but when I opened it back up, a lot of my curly brackets are highlighted in yellow, and I can't seem to fix it. The closing brackets are matched up with opening brackets, so I don't see what the issue is.
Here is a picture of the problem:
How can I fix this?
Did you do a search for the closing bracket?
Try the following, in command mode
:set nohlsearch
You can use :noh to turn off highlighting of previously searched term.
You can do set nohl that will turn off the highlighting for the session. Reopening will highlight again.
To fix that, search anything that you don't like, for instance /""
I've been searching a lot in the web and in here but I can't find a solution to this.
I have to make two replacements in all registry paths saved in a text file as follows:
replace all asterisc with: [#42]
replace all single backslashes with two.
I already have two expressions that do this right:
1st case:
Find: (\*) - Replace: \[#42\]
2nd case:
Find: ([^\\])(\\)([^\\]) - Replace: $1$2\\$3
Now, all I want is to join them together into just one expression so that I can do run this in one time only.
I'm using Notepad++ 6.5.1 in Windows 7 (64 bits).
Example line in which I want this to work (I include backslashes but i don't know if they will appear right in the html):
HKLM\SOFTWARE\Classes\*\shellex\ContextMenuHandlers\
I already tried separating it with a pipe, like I do in Jscript (WSH), but it doesn't work here. I also tried a lot of other things but none worked.
Any help?
Thanks!
Edit: I have put all the backslashes right, but the page html seem to be "eating" some of them!
Edit2: Someone reedited my text to include an accent that doesn't remove the backslashes, so the expressions went wrong again. But I got it and fixed it. ;-)
Sorry, but this was my first post here. :)
As everyone else already mentioned this is not possible.
But, you can achieve what you want in Notepad++ by using a Macro.
Go to "Macro" > "Start Recording" menu, apply those two search and replace regular expressions, press "Stop Recording", then "Save Current Recorded Macro", there give it a name, assign a shortcut, and you are done. You now can reuse the same replacements whenever you want with one shortcut.
Since your replacement strings are totally different and use data that come not from any capture (i.e. [#42]), you can't.
Keep in mind that replacement strings are only masks, and can not contain any conditional content.