If I try to use a regular expression in Find (F3) it appear not to work:
[T]opic highlights both 'Topic' & 'topic' in my code.
Is my syntax wrong or does VSCode not really do regular expressions (this may be a whole 'visual studio' thing).
Thanks for looking.
Just enable a case sensitive search:
Actually, a character class is not necessary here, you can search for just Topic. A character class is handy when you need to match a single character from a known set, and here, it does not look to be the case.
Related
I'm using a regular expression to find character entries (e.g. '[any single character]' or '\[any single character]') and I noticed my current regex is missing '\''. Can anyone help me understand why and how to fix it? My current regex is ('.'|'\\.')
I'm writing my program using C++, in case that matters to anyone.
Thanks.
Answer: ('\\.'|'.')
The search wasn't working because it matched the first option - '.'. Switching the order made it try to match '\.' first.
I have a large LaTeX document where I have defined a macro like this:
\newcommand{\abs}[1]{\left|#1\right|}
I want to get rid of it by replacing in all the document \abs{...} by \left|...\right|, so I am thinking in a regular expression. I am familiar with their basics but I do not know how to find the bracket that closes the expression, given that the following situations are possible:
\abs{(2+x)^3}
\abs{\frac{2}{3}}
\abs{\frac{2}{\sin(2\abs{x})}}
What I have been able to do for the moment is \\abs\{([^\}]*)\} and then replace as \left\1\right|but it is only able to deal with the pieces of code of the first kind only.
By the way, I am using the TeXstudio regular expression engine.
Well, I did a little more of research and I managed to solve it. According to this response in a similar question, it suffices to use recursive regular expressions and a text editor that supports them, for example Sublime Text 2 (I could not do it with TeXstudio). This does the trick:
Find: \\abs\{(([^\{\}]|(?R))*)\}
Replace: \\left|\1\\right|
EDIT 1: Actually this solves only the two first cases, but fails with the third, so any idea on how to improve the regular expression would be appreciated.
EDIT 2: See comment from #CasimiretHippolyte for full answer using \\abs\{((?>[^{}]+|\{(?1)\})*)\}
I would like to remove hundreds on onmouseover events from my code. the evt all pass different variables and I want to be able to use dreamwaever to find and replace all the strings with nothing.
Here is an example
onmouseover="parent.mv_mapTipOver(evt,'Wilson');"
onmouseover="parent.mv_mapTipOver(evt,'Harris');"
onmouseover="parent.mv_mapTipOver(evt,'Walker');"
I want to run a search that will identify all of these and replace/remove them.
I have tried seemingly infinite permutations of things like:
onmouseover="parent.mv_mapTipOver(evt,'[^']');"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']+');"
And many more. I cannot find the regular expression that will work.
Any/all help would be appreciated.
Thanks a ton!
"." and "(" have special meaning in regular expressions, so you need to escape them:
onmouseover="parent\.mv_mapTipOver\(evt,'[^']+'\);"
I'm not sure if this is correct dreamweaver regex syntax, but this stuff is standard enough.
Try this one:
onmouseover="parent\.mv_mapTipOver\(evt,'.+?'\);"
And see it in action here.
When using reg expressions you have to be very careful about how you handle white space. For example the following piece of code will not get caught by most of the reg expressions mentioned so far because of the space after the comma and equals sign, despite the fact that it is most likely valid syntax in the language you are using.
onmouseover= "parent.mv_mapTipOver(evt, 'Walker');"
In order to create regexp that ignore white space you must insert /s* everywhere in the regexp that white space might occur.
The following regexp should work even if there is additional white space in your code.
onmouseover\s*=\s*"parent\.mv_mapTipOver\(\s*evt\s*,\s*'[A-Za-z]+'\s*\);"
I'm currently creating a language with a friend and I would like to provide a highlighting for it in jEdit.
It's syntax is actually quite simple. The functions can only match this pattern:
$function_name(arguments)
Note that our parser is currently working without closing tag like the C-style semi-column and that we would like to keep this feature.
I created my jEdit mode and (almost) succeeded in highligting my pattern with <SPAN_REGEXP>. Here's how I did it:
<SPAN_REGEXP HASH_CAR="\$" TYPE="KEYWORD3" DELEGATE="ARGS">
<BEGIN>\$[A-Za_z0-9_]*\s*\(</BEGIN>
<END>)</END>
</SPAN_REGEXP>
But It's not good enough.
Here's what I would like:
Same color for the entire function skeleton : $func( )
Special highlighting (already defined within the ARGS rules set) for %content1% in $func(%content1%)
No highlighting for brackets not following a $func
Authorize alternative multiline syntax like
$func
(
args
)
which is for now not highlighted.
I guessed I needed to change my <BEGIN> regexp to accept newlines, but it seems that jEdit is unable to match multiline regexp for highlighting although he does it perfectly for search&replace !
I tried the (?s) and (?m) flags, the [\d\D]* workaround, even [\r\n]* but it never works.
So, here are my questions:
Does anyone know how to match multiline regexp in jEdit modes <SPAN_REGEXP> ?
If not, does anyone have any idea how to do what I need ?
As stated in the help, the SPAN_REGEXP does not support multi-line regexes. You can of course specify multi-line regexes, but they are only checked against individual lines and thus will then never match. You could post a Feature Request to the Feature Request Tracker of jEdit though if there is none for it yet.
I'm looking for a regular expression that can find and replace all the text "anytext" with "anything" in netbeans, some of the symbols also contain this text. I've done it a while back for a single file but now I want to change everything in my application & I'm struggling to get it right.
Just use find & replace to replace all instances of "anytext" with "anything". There is no difference between this and a regex find & replace, because there doesn't exist a pattern that can be easily exploited using regex. There is no difference in this case. Based on your comment, you still must manualy enter the word you want replaced and a word that will replace it.
I think you have misunderstood a bit what regular expressions are all about.
Were you looking for something like this? Where it wouldn't grab it inside word?
\banytext\b