Request: extract item name into popupmenu

Discuss and share scripts and script files...
Post Reply
yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Request: extract item name into popupmenu

Post by yusef88 »

I need to extract the item base name to choose one word and set a filter

Code: Select all

 regexmatches("<curbase>,", "\w");
 popupmenu("<curbase>|-|New|Text|Document");  //- is a menu separator
 filter "<curbase>", 8;
Attachments
2017-03-14_055931.png
2017-03-14_055931.png (2.19 KiB) Viewed 1556 times

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Request: extract item name into popupmenu

Post by bdeshi »

Code: Select all

  $filter = popupmenu("<curbase>|-|" . regexmatches(<curbase>, "\w*"));
  filter $filter, 8;
Want to include the extension? use <curname> inside the regexmatches().
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Request: extract item name into popupmenu

Post by yusef88 »

Thanks :tup:
Off-topic question: does regular expressions support non-latin characters?

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

Re: Request: extract item name into popupmenu

Post by highend »

Sure
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Request: extract item name into popupmenu

Post by yusef88 »

so why the script doesn't work with Arabic characters

Code: Select all

popupmenu("<curbase>|-|" . regexmatches(<curbase>, "\w*"));

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

Re: Request: extract item name into popupmenu

Post by highend »

Because unicode characters are supported but have their own escape sequences (for each and every char).
They are not present in "\w" (which only matches ascii chars)^^

You could just split the word and it's language agnostic afterwards...

Code: Select all

    $stripped = regexreplace(<curbase>, "(,|;|-|\.|\[|\]|\(|\)|\{|\})+", " ");
    $words = "";
    foreach($entry, $stripped, " ", "e") { $words = $words . $entry . "|"; }
    $filter = popupmenu("<curbase>|-|" . $words);
    filter $filter, 8;
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Request: extract item name into popupmenu

Post by yusef88 »

highend many thanks to you.. a little modification to ignore underscore would be appreciated

Code: Select all

 regexmatches(<curbase>, "[^_\W]+"))

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

Re: Request: extract item name into popupmenu

Post by highend »

Then add it to the $stripped = ... line?
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Request: extract item name into popupmenu

Post by yusef88 »

:beer:

Post Reply