Regular expression woes

J

Joe Smith

Mark said:
"Why do people insist on doing things the hardest way possible."? Well,
as I said in an earlier post, I wanted to do the whole thing within a
regex rather than resorting to the shell.

OK, but that doesn't answer the question. The statement

if (!/^http/i.test(some_string)) { ... }

does not resort to using the shell, and therefore is acceptable,
is it not?

Doing it with a regex + some simple programming is not the same
as resorting to the shell. So, what are your actual requirements?
-Joe
 
D

Dietmar Meier

Grant said:
Why do people insist on doing things the hardest way possible.

I don't insist on nothing. Mark announced this as a brainteaser,
nobody is actually expected to use this in a real script.

ciao, dhgm
 
M

Mark (News)

The if (! some-test) { ... } has the negation as part of the if
statement (I may have erroneously called this negation "using the
shell", whereas it might have been more precise to say "part of the if
statement"). What I was challenging was to achieve the same result, but
keeping any negations inside the RE: if(some-re-test). Hope that makes
sense. My actual requirements are to enjoy solving this challenge -
nothing more. :)
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Mark (News)
The if (! some-test) { ... } has the negation as part of the if
statement (I may have erroneously called this negation "using the
shell", whereas it might have been more precise to say "part of the if
statement"). What I was challenging was to achieve the same result, but
keeping any negations inside the RE: if(some-re-test). Hope that makes
sense. My actual requirements are to enjoy solving this challenge -
nothing more. :)

Keep in mind that there *is* a legitimate situation when such a
requirement is not bogus: some programs take a REx as a command-line
argument. Given this design, you may be forced to provide some REx
aerobatics if you want squeeze more from such programs.

[If the program is not updated often, sometimes it is easier to change
the source code. ;-]

Hope this helps,
Ilya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top