Page 1 of 1
Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 11:47
by thecon
Hello!
I'm having difficulty formulating a regexp to track down filenames that contain monetary sums without the euro sign.
Of course, a visual filter like
>.+\d+\.\d{2}.+
should capture filenames containing things like
stuffinhere_34.52_otherstuff.ext
stuffinhere_4.52_otherstuff.ext
stuffinhere_1503.52_otherstuff.ext
(notice I don't use commas for thousands)
however, since I've already transformed many files to have the euro sign in front of the filenames such as
stuffinhere_€34.52_otherstuff.ext
stuffinhere_€4.52_otherstuff.ext
stuffinhere_€1503.52_otherstuff.ext
I wish to construct a XYplorer regexp to omit those results that contain the euro symbol.
Unfortunately, the visual filter
>.+[^€]\d+\.\d{2}.+
doesn't work, as I'm getting also the files with euro symbols in them.
As a workaround, I search with the regexp and then I visual filter
!€
But that is not convenient.
Can you formulate a regexp to cover my problem?
Also, (not so important), if I have commas for thousands, millions etc (I usually don't, but let's say), what would be the new regexp?
Thank you!
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 12:01
by highend
All your files use a "_" before the digits begin so you don't need to exclude the € specifically but just modify the regex to begin with _ before the digits...
And mostly the same if you want to capture the "," as well:
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 13:37
by thecon
Clever, thanks!
I just saw that the _ is not necessarily before the number. It could be absent. So, any ideas about the regexp regardless of the _?
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 14:04
by highend
Normally you would use e.g.
Code: Select all
[^\x{20AC}] before the first digit
but this doesn't work atm. Maybe a limitation of the VB6 regex. No time to think about it.
A reversed form would be to only include the letters that do exist (but that depends if you're using only the plain english alphabet + additional characters like "_", etc.).
At least for your specific example, this would work:
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 14:39
by bdeshi
Also works. But either I missed something blatantly obvious, or [^\u20AC] doesn't work (

?). Hence the ! negator.
(this is a VF pattern btw)
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 15:31
by highend
I thought he wanted to see only those files that match the pattern AND except those that match the pattern and use the € sign?
The negation will show all other files / folders as well (but I don't know if that matters depending on files in those folders)...
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 16:46
by thecon
That's true. The code:
isn't exactly what I want, as it captures also filenames without any currency information.
It's strange because
or
or
captures all filenames with €, but
or
captures everything, regardless if it has € or not. Maybe a limitation (or bug) of the VB regex engine as previously mentioned.
Perhaps if the visual filter could accept something like the following:
we could bypass that limitation AND provide for an extra, powerful XYplorer feature

Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 17:16
by TheQwerty
What about a script?
Code: Select all
filter('#[.,]##', 4);selfilter '€';sel 'i';#359;sel '';
Filter to those containing currencies.
Select those with the euro sign.
Invert the selection.
Command #359 is
View | Tab | Filter By Selection(s)
Then select none.
Though at that point you could just perform the entire filter by script.
Re: Regexp for nonexistent euro sign.
Posted: 22 Feb 2016 17:35
by thecon
Excellent, that works!
Thanks.
(Do take a look at my suggestion for multi-filters

Re: Regexp for nonexistent euro sign.
Posted: 23 Feb 2016 02:00
by Marco
XY regex engine is working properly, this time (

).
In particular, [^€] is processed as it should and correctly matches whatever is not an euro sign, ie. any letter or digit or whatever, and a file extension gives you those characters. You can try yourself by creating extensionless files called £, $ and € and VFing them with [^€]. The pound and the dollar only will survive.
So why are you still getting matches containing the euro sign after you run >.+[^€]\d+\.\d{2}.+ ? Because this regex isn't correct.
You're asking for a bunch of characters (1), followed by something that is not an € (2), and then at least a digit (3), a dot (4), two figures (5) and another bunch of characters (6). You run that regex VF against those three filenames you provided as example, and only two will survive. Why? Because
Code: Select all
stuffinhere_€4.52_otherstuff.ext
1+++++++++++++
2 +
3
4
5
6
>>> NOT A MATCH (can't find a digit for 3)
stuffinhere_€34.52_otherstuff.ext
1+++++++++++++
2 +
3 +
4 +
5 ++
6 +++++++++++++++
>>> MATCH!!!
stuffinhere_€1503.52_otherstuff.ext
1+++++++++++++
2 +
3 +++
4 +
5 ++
6 +++++++++++++++
>>> MATCH!!!
A regex-only solution is quite trivial. Since digits are creating the trouble because they're non-€, you should exclude them like this (solutions that comprises the dot v comma question):
(Note that the only special characters or metacharacters inside a character class are the closing bracket (]), the backslash (\), the caret (^) and the hyphen (-). The usual metacharacters are normal characters inside a character class, and do not need to be escaped by a backslash - from
http://www.editpadpro.com/manual/EditPadPro.pdf , page 254)
Re: Regexp for nonexistent euro sign.
Posted: 23 Feb 2016 05:57
by bdeshi
That's some topnotch explanation. Thanks Marco!
Marco wrote: In particular, [^€] is processed as it should and correctly matches whatever is not an euro sign
Of course!

Re: Regexp for nonexistent euro sign.
Posted: 23 Feb 2016 12:33
by thecon
That was great! Thanks!