Match possibility with wildcards - ala reverse like

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47
Location: XY64 Latest Beta , Win 11, 96dpi, 100%

Match possibility with wildcards - ala reverse like

Post by nerdweed »

Not sure if this would be possible. Take below unfinished code (which is partly from the Qwerty) as example to take leverage of the CEA scripting.

The pathsExact matching is done in an elegant manner using formatlist as I can pass the list of exact paths and filter the current path. However, for wild card patterns, I have to fall back on a foreach loop. Can that be achieved in some other way - missing switch case

Code: Select all

"CEA"
	$main = "Fav Folders;550 | Fav Files;564 | Favorites;_favsFull | - | Drives;526 | Drives+Special;_drivesSpecial | - | All Tabs;690 | Pane Tabs;538" ;
	$pathsExact = "Recycle Bin | Empty Recycle Bin;642|_|paper:Cloud | Empty Paper Folder;777" ;
	$pathsWild = "paper* | Empty Paper Folder;777|_|*Downloads* | Show Drives;526" ;
	$match = formatlist($pathsExact, f, "|_|", "<curpath>*") ;
	if ($match) {
		$main = $main . " |" . gettoken($match, 2, "|") ; //First match wins
	} else {
		$pattern = "paper*|*Downloads*" ;
		foreach ($path, $pattern, "|") {
			if (<curpath> LikeI "$path") {
				$match = formatlist($pathsWild, f, "|_|", "$path") ;
				$main = $main . " |" . gettoken($match, 2, "|") ; //First match wins
				break ;
			}
		}
	}
	if (get("FocusedControl") == "T") {
		#690;
	} else {
		$choice = popupmenu($main, -1, -1, 1, -1, 0, " | ", ";", "Esc") ;
		end ($choice == "Esc") ;
		if ($choice Like "_*") {
			sub "$choice";
		} else { #$choice; }
	}
"_favsFull"
	popupmainmenu 'favorites';
"_drivesSpecial"
	$sub=get("Drives", ," | ") . " | " . %computer% . " | " . %personal% . " | " . %net% . " | " . %recycler% ;
	$choice = popupmenu($sub, -1, -1, 1, -1, 0, " | ", ";", "Esc") ;
	end ($choice == "Esc") ;
	goto "$choice";


nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47
Location: XY64 Latest Beta , Win 11, 96dpi, 100%

Re: Match possibility with wildcards - ala reverse like

Post by nerdweed »

I think this may be possible using named regex. Any idea. :?:

Post Reply