Page 1 of 1
Request: extract item name into popupmenu
Posted: 14 Mar 2017 05:14
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;
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 06:18
by bdeshi
Code: Select all
$filter = popupmenu("<curbase>|-|" . regexmatches(<curbase>, "\w*"));
filter $filter, 8;
Want to include the extension? use <curname> inside the regexmatches().
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 13:59
by yusef88
Thanks
Off-topic question: does regular expressions support non-latin characters?
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 14:12
by highend
Sure
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 14:19
by yusef88
so why the script doesn't work with Arabic characters
Code: Select all
popupmenu("<curbase>|-|" . regexmatches(<curbase>, "\w*"));
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 14:49
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;
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 15:13
by yusef88
highend many thanks to you.. a little modification to ignore underscore would be appreciated
Code: Select all
regexmatches(<curbase>, "[^_\W]+"))
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 15:16
by highend
Then add it to the $stripped = ... line?
Re: Request: extract item name into popupmenu
Posted: 14 Mar 2017 15:30
by yusef88