I am using NetBeans 8.2. I am working in the code editor window and trying to use regex in combination with the NetBeans find/replace feature. I have the regex button turned on.
I am trying this
on this code
specStripWidthUpper: $("#uniflytebundle_quoteitem_QuoteRing_specStripWidthUpper"),
specStripWidthLower: $("#uniflytebundle_quoteitem_QuoteRing_specStripWidthLower"),
The result I would like would take 1st Category found in find regex
specStripWidthUpper
and repeat it on other side of colon ":" like
specStripWidthUpper:specStripWidthUpper
instead it replaces the selection with $1. looking like
specStripWidthUpper:$1,
specStripWidthLower:$1,
Is there a NetBeans setting to run regex for the replace input window or am I doing something incorrect?
Thank you in advance for your time and effort.
Netbeans (8.2?) does not like the lookarounds. I do not know if this is a new thing but you can get around it with a simplified pattern.
However, your pattern does not capture the part you want to repeat, i.e. specStripWidthUpper (you can see this when you toggle the Select option).
Try it like this:
(\w+)(?:\:)(.*),
$1:$1
You might be required to anchor the query to avoid false positives.
Related
I have code that looks like
'.Parameters.Add("p_Date", OracleClient.OracleType.DateTime).Value
or
.Parameters.Add("p_Date", OracleClient.OracleType.DateTime).Value
The only difference is that one is commented and the other is not.
I want to search for all code in my project that aren't commented so I can focus on that
I don't mind downloading an IDE that you're familiar with to help me ONLY find those lines that are NOT commented.
Using Notepad++
The simplest way is to find with Regular expression checked.
(?<!')\.Parameters\.Add\("p_Date", OracleClient\.OracleType\.DateTime\)\.Value.*$
or
(?<!')\.Parameters\.Add.*$
To filter lines that don't begin with cmd., add (?<!cmd) before \.Parameters, so the regex becomes:
(?<!')(?<!cmd)\.Parameters\.Add.*$
I have phone numbers on my file and I would like to surround each of them with braces, so if I have this:
"+49-1111"
"+49-2222"
I would like to run a replace operation and to get this:
["+49-1111"]
["+49-2222"]
Is that possible with the current vs code find/replace action?
If it is a dup sorry but I could find any explanation anywhere.
Thanks
This is more relevant to regular expression.
Find ("\+\d{2}-\d{4}"), replace the occurrences with [$1]
Be sure to turn the "Use Regular Expression" switch on.
I'm working on migrating a database into a sql project, and need to replace all instances of cross-database calls with a SQLCMD variable, and am struggling to write a regex to help me find the places I still need to update.
In the SQL, we have the following:
MyOtherDatabase.MySchema.MyTable
[MyOtherDatabase].MySchema.MyTable
Which I need to change to:
[$(MyOtherDatabase)].MySchema.MyTable
So far, I've come up with the following regex:
([^(]M|^M)yOtherDatabase
Which finds all places where "MyOtherDatabase" is used, and hasn't been replaced with the variable.
HOWEVER, it's also picking it up in SQL comments, such as:
-- I don't want to find MyOtherDatabase in this line
and
FROM ADifferentPlace -- Used to be MyOtherDatabase
If this was only a few instances, I'd live with it, but I've currently got 560 matches, most of which are one or the other of the above, making it very easy for human error to get in the way.
I'm using this regex in the "Search" box within Visual Studio 2015, with the "use regex" checkbox ticked.
any advice would be helpful!
Edit
Also need to NOT find the following:
from MyTable -- from MyOtherDatabase.MySchema.MyTable
If your environment supports variable-length negative lookbehinds, you could use the following to avoid matching any commented section :
search for (?<!--.*)MyOtherDatabase(?=]?\.)
replace by $(MyOtherDatabase)
If it doesn't, you can still match lines from the start :
search for ^((?:[^-]|-[^-])*)MyOtherDatabase(]?\.)
replace by \1$(MyOtherDatabase)\2
I was trying to update one of my old Xcode 7 answers that described how to do regular expression matching. However, I can't get the Textual Matching Style to work now. In Xcode 7, I could do something like this:
which gave me pattern matching like this:
But in Xcode 8 the green bubbles don't show up. I get a (\w+) but that doesn't match anything in the Textual style anymore. And when I am in The Regular Expression Matching Style, I don't have all the nice Insert Pattern hints anymore.
What am I doing wrong?
Note: I'm not asking for the regex answer. I'm asking how to get the Insert Pattern hints to work.
You switched your find options Matching Style from Text to Regular Expression. To revert this, simply click on the magnifying glass next to the search field, select Edit find options... and set the Matching Style back to text.
I'm fairly new to figuring out how Regex works, but this one is just frustrating.
I have a massive XML document with a lot of <description>blahblahblah</description> tags. I want to basically remove any and all instances of <description></description>.
I'm using Eclipse and have tried a few examples of Regex I've found online, but nothing works.
<description>(.*?)</description>
Shouldn't that work?
EDIT:
Here is the actual code.
<description><![CDATA[<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3"><th>ID</th><td>308</td></tr></table></center>]]></description>
I'm not familiar with Eclipse, but I would expect its regex search facility to use Java's built-in regex flavor. You probably just need to check a box labeled "DOTALL" or "single-line" or something similar, or you can add the corresponding inline modifier to the regex:
(?s)<description>(.*?)</description>
That will allow the . to match newlines, which it doesn't by default.
EDIT: This is assuming there are newlines within the <description> element, which is the only reason I can think of why your regex wouldn't work. I'm also assuming you really are doing a regex search; is that automatic in Eclipse, or do you have to choose between regex and literal searching?