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

Help Creating an Alias RegEx with Multiple Optional Parameters

(1/2) > >>

CatamountJack:
Hi all,

Perhaps this is more of a general-case regex problem than an FARR problem, but since I'm trying to use it to make FARR work better, I'm hoping someone here might offer some helpful advice...

I have an alias, let's call it "test", and I want to *optionally* pass one or more parameters to it, separated with a space.
-- If I knew there was always going to be one parameter, I might use ^test (.*)
-- If I want that parameter to be optional, I've found that ^test ?(.*)? seems to work just fine
-- But how can I specify multiple optional parameters?

The alias will run a batch file that will handle the optional input.     (batchfile.bat $$1 $$2 $$3)

I've visited numerous sites over the last couple of weeks that explain how to create/use regular expressions, and I've tried all sorts of combinations, but I've yet to find a solution.

Thanks in advance!



herojoker:
You first have to specify which content $$1, $$2 etc. may have. Is it possible that they also contain spaces?

CatamountJack:
Hmmmm.....

In the instances I'm planning on using this for, $$1, $$2, etc would be just short words (perhaps numbers).  In my case, there would be no spaces within each of those arguments since I want to use spaces as the separators between arguments.  I'm not sure whether the batch file I'm passing these to would complain if there were extra spaces included at the beginning/end of each argument or not - I just tried testing it but my computer is having some other serious issues at the moment.

Thanks!

lanux128:
among Farr's default alias, there is one for nircmd command-line utilities where multiple parameters are used. you can take a look and try to figure out. also if you can post a screenshot of your alias config window, then it'd be easier to make a suggestion.

CatamountJack:
Well, it turns out I'm just not very bright (and it only took me a month to figure that out!).  Since command line arguments in batch files are delimited by spaces anyway and, in this case, since I'm using spaces to delimit the arguments in FARR, I don't actually need to specify multiple capturing groups in the regex.  The screenshot is how I'm setting this up:



The first line in the results box allows me to enter an argument, multiple arguments, or even no argument at all.  I realize the way this particular one is set up I don't need $$2.  The second and third lines are pre-defined examples of what the different arguments might look like.

My question does still stand, however, if I were to use something other than spaces to delimit the different arguments.  I think this would also be useful in the case of czb's Table Data Search plugin, where (if I understand it right) you currently need to create a specific regex to match the data you are filtering.  (e.g. if you are filtering on 4 columns of data, you need to create a regex with 4 capturing groups.)

So, my question is - how can I create a regex that will allow me to enter an arbitrary number arguments (bonus points if it also allows you to use a variety of delimiters).  In the case of my alias above, I might not want to enter any arguments, or maybe I want to enter 1, or 2.  In the case of the Table Data Search plugin, there could be more.  Is there a way to create a regex that is flexible enough to do this?

@lanux128:  Thanks for the suggestion, but from what I can see, while the nircmd aliases do use multiple arguments, the user needs to fill them all in to make the alias work - so that's a bit different than what I'm looking for.

Thanks!

Navigation

[0] Message Index

[#] Next page

Go to full version