ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Find And Run Robot

$$c for $$2 or another regular expression?

(1/2) > >>

herojoker:
To reach some flexibility, I set up several different spellings for the same command, for example
^(vid|vids|video|videos) (.*)
as a regular expression pattern. Then I use $$2 to access the entered text in the actual commands.
Now I've found $$c which takes the clipboard text if $$1 is empty and $$1 otherwise. Unfortunately this is not so helpful in that situation.

Is there a $$c - like expression for $$2, $$3 etc.? If not, how could I rewrite the expression to have the actual user input stored in $$1?
-> What I really need is just another pair of grouping brackets which is not a capturing group.

d4ni:
You can use (?:regex) to use a non-capturing group.

In your case ^(?:vid|vids|video|videos) (.*)

herojoker:
Thanks!
Is this documented somewhere?

d4ni:
I got it off regular-expressions.info, here.

herojoker:
Your hint worked - but what if I want to access the non-captured groups in the "Result Filter for RegEx"?

Example:
What I want:
a) Typing wiki should result in the following aliases being shown: Wikipedia (Deutsch), Wikipedia (English), Wiktionary (Deutsch), Wiktionary (English), Wikiquote (Deutsch), Wikiquote (English), ..., Wikimedia
a²) Typing wikt should show only the Wiktionary entries.
b) These aliases should be directly accessible when typing wiki (no space after it), which means that every entry can be activated without having to enter a group (which would require pressing enter twice in total)
c) If no argument is manually entered ([space]+words), the last selected or copied text should be used
d) Adding more characters, e.g. a p should narrow the displayed aliases (e.g. to the two Wikipedia entries)
e) The original order of the entries should be preserved

Examples: In the following "foobar" is in the clipboard. _ is used to display the space character at the end of inputs.

1) wikipediaX, wikipX show normal file/alias search for wikipediaX, wikipX
2) wiki, wiki_ show all wiki-related aliases with foobar as argument
3) wiki baz shows all wiki-related aliases with baz as argument

4) wikip, wikipe, ..., wikipedia, wikip_, wikipe_, ..., wikipedia_ show both Wikipedia entries with foobar as argument
5) wikip baz, wikipe baz, ..., wikipedia baz show both Wikipedia entries with baz as argument

6) wikt, wikti, ..., wiktionary, wikt_, wikti_, ..., wiktionary_ show both Wiktionary entries with foobar as argument
7) wikt baz, wikti baz, ..., wiktionary baz show both Wiktionary entries with baz as argument


The alias lines currently look like this:
Wikipedia (English) - $$c | htmlviewurl http://en.wikipedia.org/w/index.php?title=Special:Search&search=$$c /ICON=icons\wikipedia.ico

What I tried:
1. One big alias group called wiki
1.1 With regular expression ^wiki (.*)  ->  a), b), c) OK but d) does not work.
1.2 With regular expression ^(?:wiki|wikipedia|wiktionary|wikiquote|wikibooks|wikiversity|wikinews|wikimedia) (.*)  -> a), b), c) OK but d) does not work completely. Typing wikiquote does show results but it shows all results. Not using (?:...) would result in $$1 being used which would make $$c unusable, therefore c) unfulfilled.

2. Many small alias groups "wikipedia", "wiktionary", "wikiquote", "wikibooks", "wikiversity", "wikinews", "wikimedia". With regular expression ^(?:wiki|wikipedia) (.*), ^(?:wiki|wiktionary) (.*) etc.  -> Typing wiki hides the wiktionary alias group -> unacceptable

3. Many small alias groups, all called "wiki"
3.1 Using regular expressions like ^wiki(?:pedia|pedi|ped|pe|p)? (.*), ^wik(?:i|t(?:ionary|ionar|iona|ion|io|i)?) (.*)  -> a), b), c) OK but d) does not work
3.2 Using regular expressions like ^wiki(?:pedia|pedi|ped|pe|p)?\ ?(.*), ^wik(?:i|t(?:ionary|ionar|iona|ion|io|i)?)\ ?(.*)  -> a), b) OK, c), d) almost OK since entering wikiped shows the wikipedia alias with copied text (good) and the wiktionary alias with "ped" as argument.


Do you have any ideas how to realize what I want?

Using "Result Filter for RegEx" hurts requirement e) - I want the results only to be filtered - not sorted.

I think the easiest (and also the most general) solution would be
1. An option (perhaps inline) that the Result Filter does not changes the alias order
2. A function like this: ifempty(variable1, variable2)=variable1 if variable1 is not empty, variable2 otherwise

With this I could simply use a big alias group with the regular expression ^(wik(?:i|t)[^\ ]*)\ ?(.*) and entries using ifempty($$2,$c).

Navigation

[0] Message Index

[#] Next page

Go to full version