Welcome Guest.   Make a donation to an author on the site October 24, 2014, 06:15:25 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: $$c for $$2 or another regular expression?  (Read 3593 times)
herojoker
Participant
*
Posts: 124


View Profile Give some DonationCredits to this forum member
« on: August 28, 2008, 01:06:53 PM »

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.
Logged
d4ni
Supporting Member
**
Posts: 128


View Profile Give some DonationCredits to this forum member
« Reply #1 on: August 28, 2008, 01:18:49 PM »

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

In your case ^(?:vid|vids|video|videos) (.*)
Logged
herojoker
Participant
*
Posts: 124


View Profile Give some DonationCredits to this forum member
« Reply #2 on: August 28, 2008, 01:44:52 PM »

Thanks!
Is this documented somewhere?
Logged
d4ni
Supporting Member
**
Posts: 128


View Profile Give some DonationCredits to this forum member
« Reply #3 on: August 28, 2008, 02:06:44 PM »

I got it off regular-expressions.info, here.
Logged
herojoker
Participant
*
Posts: 124


View Profile Give some DonationCredits to this forum member
« Reply #4 on: August 31, 2008, 11:28:15 AM »

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...pecial: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).
« Last Edit: September 01, 2008, 10:27:57 AM by herojoker » Logged
d4ni
Supporting Member
**
Posts: 128


View Profile Give some DonationCredits to this forum member
« Reply #5 on: September 01, 2008, 12:17:20 PM »

Unfortunately I do not have any experience using the 'Result Filter for RegEx' feature. I hope someone else - like Mouser - can help you smiley
Logged
mouser
First Author
Administrator
*****
Posts: 33,581



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: September 01, 2008, 11:28:54 PM »

if i forget to reply to this in next day or two please remind me -- i just need time to digest it.
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.035s | Server load: 0.13 ]