TFileListBox Mask Issue - regex

The definition for TFileListBox.Mask is:
Set Mask to a regular expression to limit the list box to files that
match the mask. The value of the mask is a file name that may include
wildcards. The asterisk (*) is a wildcard which matches any number of
arbitrary characters. The question mark (?) is a wildcard which
matches a single arbitrary character. The file mask *.* displays all
files, which is the default value.
The * wildcard works fine. However the ? wildcard does not seem to work. I am trying to filter data files that have 14 digits. Examples would be:
012345678909090.dat
012345678900123.dat
012345678901234.dat
012345678901235.dat
012345678901236.dat
If you were to set the mask to *.23?.dat the last four data files are returned. However, the second data file (012345678900123.dat) should not be returned if the ? wildcard is doing its job.
By the way, this "problem" occurs in Raize Components TRzFileListBox and I imagine all others that derive from TFileListBox, too.
Any help with this?
Thanks in advance.

Related

Regular Expression help to find letter in XML number field

I am getting an error importing an XML file into a custom program. Other files import correctly. However, one file produces an error from a float field. I am using Notepad++ search function with Regular Expression to try and find the issue in the XML file.
When I use <milepost>([a-zA-Z0-9.]+)</milepost> I get around 30,000 results which is the correct number of records but the field is supposed to be DOUBLE. When I use <milepost>([0-9.]+)</milepost> I only get 29,994 records. This tells me that the import is most likely failing because there are letters in my number fields.
I have tried a number of variations like:
<milepost>([\S\D\d]+)</milepost>
<milepost>(.*?)</milepost>
<milepost>([\Sa-zA-Z]+)</milepost>
<milepost>([0-9.\w]+)</milepost>
etc.
Each of these returns the expected 30,000 records.
When I try to search for letters using :
<milepost>([a-zA-Z.]*)</milepost>
<milepost>([a-zA-Z]+)</milepost>
<milepost>(^[a-zA-Z]+$)</milepost>
<milepost>([a-zA-Z.a-zA-Z]+)</milepost>
I get 0 results (most likely because it excludes numbers)
I did manage to find one of the records I am looking for using this method:
<milepost>173.811818181818a</milepost>
But I do not feel like scrolling through 30,000+ lines to look for 5 more records with a letter in them.
Is there a regular expression that will return to me ONLY the values that have a letter/letters in them while allowing numbers? (Fields with only numbers and a period should be excluded)
The 6 problem records presumably contain a mixture of letters and numbers, but your searches for records containing letters will only match records consisting exclusively of letters.
Try
<milepost>.*[a-zA-Z].*</milepost>
which matches any record containing an ASCII letter in its value, as well as allowing other characters such as digits.
What you want is a negative look-ahead. Something like
<milepost>(?![0-9.]+</milepost>)
should be very close.
In plain English <milepost> not followed by exclusively digits and dots and a closing </milepost>

Getting Beyond Compare to Match Similar Lines Properly

I am using Beyond Compare 4.1.6 to diff text configuration files. There is one configuration parameter per line, and each line is formatted as follows:
:=
I would like to configure Beyond Compare such that it will align only lines when the : portion of the line is exactly the same in both files. Put differently, everything from the beginning of the line up to and including the colon must match exactly for the two lines to be aligned. Note that a colon cannot occur in , so the colon I want Beyond Compare to base its alignment decision on will always be the first colon in the line.
An example is:
# FILE 1
abcdefgh:string=5
# FILE 2
abcdefkh:string=5
Beyond Compare aligns these two lines even though I don't want it to.
I've been unable to coerce Beyond Compare to compare lines as desired by editing its grammar rules or by tweaking other features.
How may I get Beyond Compare to match lines as described above?
Thank you!
You can compare it with a table compare.
Then you must set the = as field separator:
When you did this, you have two columns and the first is the key columns (if not, you can define it).
After this you get the result you want (if I understood your question right):
If you need it often, you may store the setting in a file format.

RegEx optional group matching

I'm trying to figure out how to create a regex that would encompass both of the following lines:
02-09-16 08:57PM 24768 Invoice - Copy.docx
05-14-16 08:49PM <DIR> Bin
Both are the result of a directory listing. The first being a file which contains the file size. The second is a directory with no size but contains the type <Dir>.
This allows me to capture all of the data into named groups but the first line's size is capture into the Type field:
(?<Date>\S+)\s+(?<Time>\S+)\s+(?<Type>\S+)\s+(?<Name>.+)
If possible, I'd like to end of with both a Type and Size. I'm not sure how to look for both of these at the same time but ignore one or the other if one is found.
Update : Based on Wiktor's response I've update the Regex and gotten closer :
(?<Date>\S+)\s+(?<Time>\S+)\s+(?:(?<Type>\S+)|\d+)\s+(?<Name>.+)
Using this I can easily parse both lines. However first line 24768 end's up in the Type group. Is it possible to have both a Type and an additional Size group? Logic being something like If you run into characters ('<Dir>') for example, that is the Type; if you run into numbers (24768) that is the Size
Just group the type and size captures into a a non-capturing or-group:
^(?<Date>\S+)\s+(?<Time>\S+)\s+(?:(?<Size>\d+)|(?<Type>\S+))\s+(?<Name>.+)$
The size field will pick up the digits, else you get a type.

How to format a WinMerge fllter to ignore part of the line

I would like WinMerge to compare the full text but exclude a variable substring.
Orientation="West" PhysicalAddress="2395226" DefFieldFrmt="Uf4d0" UnitCustomText="sec"
Orientation="West" PhysicalAddress="2395230" DefFieldFrmt="Uf4d1" UnitCustomText="sec"
In the lines above I want to ignore the PhysicalAddress="xxx" and locate the changed DefFieldFrmt="Uf4d1"
I have tried adding the filter:
PhysicalAddress=".*"
However this filters the complete line.
The actual text before and after the PhysicalAddress="xxx" will vary so I need a filter that says: match prefix and match suffix but ignore target variable substring.
Help please.
According to the documentation, is not possible to use the line filters for this:
When a rule matches any part of the line, the entire difference is ignored. Therefore, you cannot filter just part of a line.
However, since WinMerge's source code is on GitHub, it is possible to add a feature request for this to its list of issues.

Notepad++ - Selecting or Highlighting multiple sections of repeated text IN 1 LINE

I have a text file in Notepad++ that contains about 66,000 words all in 1 line, and it is a set of 200 "lines" of output that are all unique and placed in 1 line in the basic JSON form {output:[{output1},{output2},...}]}.
There is a set of characters matching the RegEx expression "id":.........,"kind":"track" that occurs about 285 times in total, and I am trying to either single them out, or copy all of them at once.
Basically, without some super complicated RegEx terms, I am stuck because I can't figure out how to highlight all of them at once, and also the Remove Unbookmarked Lines feature does not apply because this is all in one line. I have only managed to be able to Mark every single occurrence.
So does this require a large number of steps to get the file into multiple lines and work from there, or is there something else I am missing?
Edit: I have come up with a set of Macro schemes that make the process of doing this manually work much faster. It's another alternative but still takes a few steps and quite some time.
Edit 2: I intended there to be an answer for actually just highlighting the different sections all at once, but I guess that it not possible. The answer here turns out to be more useful in my case, allowing me to have a list of IDs without everything else.
You seem to already have a regex which matches single instances of your pattern, so assuming it works and that we must use Notepad++ for this:
Replace .*?("id":.........,"kind":"track").*?(?="id".........,"kind":"track"|$) with \1.
If this textfile is valid JSON, this opens you up to other, non-notepad++ options, like using Python with the json module.
Edited to remove unnecessary steps