Regexp for nonexistent euro sign.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
thecon
Posts: 75
Joined: 09 Nov 2015 19:08

Regexp for nonexistent euro sign.

Post 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!

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Regexp for nonexistent euro sign.

Post 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...

Code: Select all

>.+_\d+\.\d{2}.+
And mostly the same if you want to capture the "," as well:

Code: Select all

>.+_\d+[\.,]\d{2}.+
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 75
Joined: 09 Nov 2015 19:08

Re: Regexp for nonexistent euro sign.

Post 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 _?

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Regexp for nonexistent euro sign.

Post 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:

Code: Select all

>^[a-z0-9_]+\d+[\.,]\d{2}.+
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Regexp for nonexistent euro sign.

Post by bdeshi »

Code: Select all

!>^.+\u20AC\d+[\.,]\d{2}.+
Also works. But either I missed something blatantly obvious, or [^\u20AC] doesn't work ( :bug: ?). Hence the ! negator. :whistle:
(this is a VF pattern btw)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Regexp for nonexistent euro sign.

Post 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)...
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 75
Joined: 09 Nov 2015 19:08

Re: Regexp for nonexistent euro sign.

Post by thecon »

That's true. The code:

Code: Select all

!>^.+\u20AC\d+[\.,]\d{2}.+
isn't exactly what I want, as it captures also filenames without any currency information.

It's strange because

Code: Select all

>€
or

Code: Select all

>[€]
or

Code: Select all

>[\u20AC]
captures all filenames with €, but

Code: Select all

[^€]
or

Code: Select all

>[^\u20AC]
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:

Code: Select all

((>.+\d+\.\d{2}.+) AND (!>€))
we could bypass that limitation AND provide for an extra, powerful XYplorer feature ;)

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Regexp for nonexistent euro sign.

Post 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.

thecon
Posts: 75
Joined: 09 Nov 2015 19:08

Re: Regexp for nonexistent euro sign.

Post by thecon »

Excellent, that works!

Thanks.

(Do take a look at my suggestion for multi-filters ;)

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: Regexp for nonexistent euro sign.

Post by Marco »

XY regex engine is working properly, this time ( :mrgreen: ).
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):

Code: Select all

^.+?[^€\d]\d+?[.,]\d{2}.+
(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)
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Regexp for nonexistent euro sign.

Post 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! :oops:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

thecon
Posts: 75
Joined: 09 Nov 2015 19:08

Re: Regexp for nonexistent euro sign.

Post by thecon »

That was great! Thanks!

Post Reply