Can a regex be used as input method? [closed] - regex

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
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...

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

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.

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?

Related

One Regex, 2 results [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
I am using XMPie and need a regex to character count for me. My Regex is ^[\S\s]{1,800}$ but I am getting a different result with the refresh preview button than the next screen button. I had a support case on it and it went all the way to R&D and they basically said, there is nothing we can do, try a different expression. I think one button must be implemented with C# and the other with JS or some such thing. What seems to be happening is that one is counting a return once (refresh), while the other is counting 2 characters for it. I think it must see it as \r or \n and count that as 2. Any ideas on how I could modify my expression to prevent that? I mostly just want consistency, so making it explicitly count it twice, or not count it at all would be more livable than differing results, especially as refresh is lower.
Thanks so much for any help!
I have tried a slew of different expressions, but I am not great with regex and nothing has given me a better result.

What does the single quote means in C++ Math programming? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
so recently I was reading a book that teach you how to program in C++ and I am at basic math stuff. I'm not a beginner in C++ but I have seen something strange that I can't find on the internet.
It is a math expression: 5*3(6' 4) and it has a single quote on it. I found didn't know what it was so I checked up on the internet for this and I found only that it is referred as prime. But I don't think it solve my problem and I don't know how correct that is.
Thanks in advance.
EDIT: I want to address all people who commented and answered (and those who will to do the same thing)in this post that I HAVE MADE A BIG MISTAKE. The real math expression was: 5*6(6*4) but my friend's book(which I got this expression) was not printed well and it looked like the one I have wrote in the past. I'm really really sorry about this....
C++14 and up allows single quote ' inside integer literals to allow for grouping digits. Thanks to this, 123'456'789 can be used as more readable equivalent to 123456789.
Depending on a country, it may be also used in mathematical (outside of C++) expressions, although Polish people would rather use 123 456 789 and UK people would use a comma AFAIK - 123,456,789. None of these is valid in C++ (or it would yield results far from expected), but it would be reasonable in mathematical text/formula.
Nevertheless, your example still wouldn't compile. There is no operator between 3 and opening bracket (.

Recognize pattern of characters [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am student in the college and I need some help with recognition pattern of characters: what it will match ? or maybe somebody can explain how does it work ?
" (k[abc]*p)+ "
Thank you for any help.
This is a bit of a vague question as you're basically asking how regular expression work.
First of all I would recommend 'Mastering Regular Expressions' which is a pretty great O'Reily book on regex.
Also, for a regex playground, I really like to use Rubular (http://www.rubular.com/) as a playground, although this is meant for ruby, it can give you a good understanding into general regex expression and comes with a nice quick reference guide.
Taking some time to figure this out yourself will be very helpful, regular expressions are not going away.
In this case, your expression is evaluating everything inside the () as one chunk. So it's looking for a k, then at least one (+) of either abc ([abc]) followed by a p, at least one time (+).
So things like kap, kabcp will match.

Is it OK to mix string parsing while learning reg ex? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm performing some regular expression exercises in Python 2.7.3, on Windows 7. Some of these exercises have me looking for similar patterns on the same line. For example, I want to use regex to capture name1 and name2...
<XML tag><more tags>[name1]</XML tag><XML2 tag>[name2]<XML2 tag></more tags>
Would it be "cheating" or "missing the point" if I used any string parsing to capture name2? I feel like using regex the correct way alone should be able to capture both of those names, but string parsing is what I've always been familiar with.
An analogy would be like someone studying recursion in C++, but using a While loop. Recursion should NOT have any While loops (although of course it may be part of some other grand design).
Good question! Many beginners come into it believing they should be able do everything with one regex match. After all, people are always saying how powerful regexes are, and what you're trying to do is so simple...
But no, the regex is responsible for finding the next match, that's all. Retrieving the substring that it matched, or finding multiple matches, or performing substitutions, that's all external to the act of matching the regex. That's why languages provide methods like Python's findall() and sub(); to do the kind of "string parsing" operations you're talking about, so you don't have to.
It occurred to me a while back that the process of mastering regexes is one of learning everything you can't do with them, and why not. Understanding which parts of the regex matching operation are performed by the regex engine, and which parts are the responsibility of the enclosing language or tool, is a good start.

Converting Regular Expressions For Use With VBA [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Forgive me if this seems basic, but I'm new to regular expressions, and I can't seem to find general information that isn't example driven.
Basically, I'd like to know what to keep in mind when converting regular expressions found around the internet for use with vba. Is it as simple as "oh, just change the non-greedy operator to this ...", or is it involved on a level that I really need to find VBA specific expressions, or get better at writing my own.
My specific example involves converting this phone number pattern
^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$
But i'm really more interested in either a general approach, or an affirmation of its futility. Thanks!
Following up on Cor_Blimey and funkwurm's comments, I have used VBScript 5.5 regexes in Office 2003 and Office 2007 VBA with good success. Details here. For anything more complicated than () and [] groups, I have found writing from scratch more effective than trying to modify an existing expression.