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.
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 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.
I am at the beginning of learning Regex, and I use every opportunity to understand how it's working. Currently I am trying to extract dates from a text file (which is in fact a vnt-file type from my mobile phone). It looks like following:
BEGIN:VNOTE
VERSION:1.1
BODY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:18.07.=0A14.08.=0A15.09.=0A15.10.=
=0A13.11.=0A13.12.=0A12.01.=0A03.02. Grippe=0A06.03.=0A04.04.2015=0A0=
5.05.2015=0A03.06.2015=0A03.07.2015=0A02.08.2015=0A30.08.2015=0A28.09=
17.11.2017=0A
DCREATED:20171118T095601
X-IRMC-LUID:150
END:VNOTE
I want to extract all dates, so that the final list is like that:
18.07.
14.08.
15.09.
15.10.
and so on. If the date has also a year, it should also be displayed.
I almost found out how to detect the dates by the following regex:
.+(\d\d\.\d\d\.(2015|2016|2017)?).+
But it only detect very few of the dates. The result is this:
BEGIN:VNOTE
VERSION:1.1
15.10.
04.04.2015
30.08.2015
24.01.2016
DCREATED:20171118T075601
X-IRMC-LUID:150
END:VNOTE
Then I tried to add a question mark which makes the .+ not greedy, as far as I read in tutorials. Then the regex looks like:
.+?(\d\d\.\d\d\.(2015|2016|2017)?).+?
But the result is still not what I am looking for:
BEGIN:VNOTE
VERSION:1.1
21.03.20.04.18.05.18.06.18.07.14.08.15.09.15.10.
13.11.13.12.12.01.03.02.06.03.04.04.20150A0=
03.06.201503.07.201502.08.201530.08.20150A28.09=
28.10.201525.11.201528.12.201524.01.20160A
DCREATED:20171118T075601
X-IRMC-LUID:150
END:VNOTE
For someone who is familiar with regex I am pretty sure this is very easy to solve, but I don't get it. It's very confusing when you are new to regex. I tried to find a hint in some tutorials or stackoverflow posts, but all I found is this: Notepad++ how to extract only the text field which is needed?
But it doesn't work for me. I assume it might have something to do with the fact that my text file is not one single line.
I have my example on regex101 too.
I would be very thankful if maybe someone can give me a hint what else I can try.
Edit: I would like to detect the dates with the regex and as a result have a list with only the dates (maybe it is called substitute?)
Edit 2: Sorry for not mentioning it earlier: I just want to use the regex in e.g. Notepad++ or an online regex test website. Just to get the result of the dates and save the result in a new txt-file. I don't want to use the regex in an programming language. My apologies for not being precisely before.
Edit 3: The result should be a list with the dates, and each date in a new line:
I want to extract all dates, so that the final list is like that:
18.07.
14.08.
15.09.
15.10.
I suggest this pattern:
(?:.*?|\G)(\d\d\.\d\d\.(?:\d{4})?)
This makes use of the \G flag that, in this case, allows for multiple matches from the very start of the match without letting any single unmatched character in the text, thus allowing the removal of all but what's wanted.
If you want to remove the extra matches as well, add |.* at the end:
(?:.*?|\G)(\d\d\.\d\d\.(?:\d{4})?)|.*
regex101 demo
In N++, make sure the options underlined are selected, and that the cursor is at the beginning. In the picture below, I replaced then undid the replacement, only to show that matches were identified (16 replacements).
You can try using the following pattern:
\d{2}\.\d{2}\.(?:\d{4})?
This will match day.month dates of the form 18.07., but it also allows such a date to be followed by a four digit year, e.g. 18.07.2017. While it would be nice to make the pattern more restrictive, to avoid false fire matches, I do not see anything obvious which can be added to the above pattern. Follow the demo link below to see the pattern in action.
Demo
I'm trying to apply a very simple regex to a Rich Text Box in Umbraco 7.
The regex I'm trying to apply is [^£\$].
I've tried some simple ones, [a-zA-Z], etc, but nothing seems to take effect.
Switching the property to as textString, and the regexes work immediately.
What am I doing wrong?
Thanks,
john
The point is that the rich text editor in Umbraco has various settings and it can show different types of content.
Regular expressions are used to find matches inside text data only.
Thus, setting the content type to textString for regex-based search to work is logical.
The fact that the regex box is not grayed out when a non-supporting mode is selected is most probably a minor bug.
Just now I was working on a fancy search and replace regular expression.
It looked good so I tested it on one entry then went to the editing area and the search and replace box went away.
I reopened the search and replace box to continue, but the selected text in the edit window replaced my search expression.
Control Z in the search box did not go back to my regex but undid the last change in the editing area.
I can't seem to find a way to get back to previous regexes in the find box. Is there any way? Googling turned up nothing.
Currently, Adobe Brackets doesn't maintain any kind of history of search and replace expressions. The feature is still missing.