tags:

views:

91

answers:

3

Hi, I saw somewhere that a regex can be used as an input method, is this possible? How? I really don't know anything else about that, I supposed that there's a way to procude Strings from a regex and feed an object with that String, again, this is only what I pictured and I don't know if it's even possible.

EDIT

I know I didn't explain myself, I was in a hurry, sorry for that. Well, long story short. Last week I saw an article about regex, and in one paragraph said "regex could be used as input", thats all it said about that, I couldn't find the article again so I think I could ask here.

Thanks for the votes down. Next time I'll make sure to explain correctly my doubts and to not piss someone off...

+5  A: 

A regular expression is not an "input method". A regular expression can be used to constrain input though.

Mark Byers
I did know that. Thanks for your reply
eiefai
Please, see my edit above.
eiefai
+1  A: 

A regex can be input, if your users are the sort that live, eat, and breathe regexps (I can't imagine who would do so...), but even so, that regexp won't become the method.

Arafangion
Sorry, I did't mean user input, I meant as a "general input". See my edit above. Thanks.
eiefai
In this situation, there's really no difference.
Arafangion
A: 

Since a regex is just a string, it is techniclaly possible to use it as either:

  • a user input to a program (not often, but I hav seen some applications accept them, usually as a form of "advanced" search filtering)
  • an input parameter to a method call which accepts a string.

Perhaps one of these is the answer you are looking for?

boomhauer
Thanks for the reply, could you elaborate on the second point? I think it's something like I wanted to know.
eiefai
Since a regex is just a string, pass it as a string parameter to a code method you wish to call. Inside the method, you will want to prase and use the regex. This of course will vary by language you are using.
boomhauer