Selecting items with double spaces - how?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Papoulka
Posts: 455
Joined: 13 Jul 2013 23:41

Selecting items with double spaces - how?

Post by Papoulka »

In scripting I'm trying to select all list pane items that have two spaces / blanks in their name. For example in the following list (where 'b' stands for a space):
  • DATAb1.txt
    DATAbb2.txt
    DATAb3.txt
I want only the file "DATAbb2.txt" to be selected.

However, neither of these work:

Code: Select all

sel "  ";
selfilter "  ";
The first selects no files; the second selects all files.

So I have two questions. (1) how can I do this and (2) shouldn't selfilter (at least) achieve this i.e. is there a bug?

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Selecting items with double spaces - how?

Post by SkyFrontier »

Selection filter (default: ctrl+m):

Code: Select all

>[\s]{2,}
(it's a regex selection)
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Papoulka
Posts: 455
Joined: 13 Jul 2013 23:41

Re: Selecting items with double spaces - how?

Post by Papoulka »

But I want to do this in a script and then operate on those selected items. In the Help, at least, neither SEL, SELECTITEMS, nor SELFILTER have any regex option. So where would I use your pattern? Is this done in SELFILTER?

Thanks for any help.

And I still wonder: shouldn't SELFILTER "bb" do what I want? If not, why not i.e. how would I know this shouldn't work?

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

Re: Selecting items with double spaces - how?

Post by bdeshi »

Code: Select all

  selfilter "*  *";                           //selects two-consecutive-spaces-in-name items
  text get('SelectedItemsPathNames', <crlf>); //an operation on selected items, lists all of them
<edit>
btw, only selfilter can select multiple items by pattern.
sel selects ONE item and optionally a number of CONSECUTIVE items before or after,
and selectitems selects by |-separated FULL names or paths. :wink:
</edit>
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Selecting items with double spaces - how?

Post by SkyFrontier »

Or this?

Code: Select all

   $a = <<<#
c:\test\soft\xy\_Titlebar Template_02.txt
c:\test\soft\xy\_TitlebarTemplate_  _01.txt
c:\test\soft\xy\_TitlebarTemplate_   01.txt
c:\test\soft\xy\_TitlebarTemplate.txt
#;
   $b = regexmatches("$a", "^.*?\b( {2,})\b.*$", "<crlf>");

   text $b;
'$a' can be filled by using get(selecteditemspathnames), alternatively (more in line with what I guess is what you want). Or a (recursive?) folderreport().
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

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

Re: Selecting items with double spaces - how?

Post by highend »

To use a precise match (it won't output entries with more than two spaces in a row):

Code: Select all

$b = regexmatches($a, "^.*?\b {2}\b.*$", "<crlf>");
One of my scripts helped you out? Please donate via Paypal

Papoulka
Posts: 455
Joined: 13 Jul 2013 23:41

Re: Selecting items with double spaces - how?

Post by Papoulka »

Sammay - thank you for showing

Code: Select all

selfilter "*  *"
I would never have figured this out from the Help on selfilter. Is there a further reference on patterns like this that I'm missing?

SkyFrontier & Highend - thanks for the info. Can you tell me how to in general select list pane files using a regex? I'm sure this can be done but can't think of any direct way.

admin
Site Admin
Posts: 66347
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Selecting items with double spaces - how?

Post by admin »

I see this (first post) as a bug. Fix comes.

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

Re: Selecting items with double spaces - how?

Post by highend »

Can you tell me how to in general select list pane files using a regex?
There is no direct way to do this. You have to use e.g. listfolder() and a regexmatch() afterwards.
One of my scripts helped you out? Please donate via Paypal

Post Reply