Help - Search - Member List - Calendar
Full Version: Decoding Regular Expression
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Support our Sponsors!
Shilpa Arvind
Hi,

I am having trouble understanding this regular expression. Any help on this
is greatly appreciated.

open FILE, "xyz";
while (<FILE>)
{
undef($regexp_var);
($regexp_var) = ($_ =~
/("(\"|[^"])+")/);
s/("(\"|[^"])+")// if (defined
$regexp_var);
}
What does " do. (Quotes) " does not require blackslash but here it is used
with blackslash. What does this do.

Shilpa

Ing. Branislav Gerzo
Shilpa Arvind [SA], on Tuesday, June 28, 2005 at 12:12 (-0700) wrote:

SA> What does " do. (Quotes) " does not require blackslash but here it is used
SA> with blackslash. What does this do.

regular expression should be written as '"' or '"'. In this case ("
is not a special character), should be escaped with ''. So in general
it does the same, but maybe author has some syntax highlighting, and
when he writes '"foo"' editor does not highlight those words. Just
try.

--

How do you protect mail on web? I use http://www.2pu.net

["I'm investing in German currency once again", Tom remarked.]

Jay Savage
On 6/28/05, Shilpa Arvind <[Email Removed]> wrote:
QUOTE
Hi,

I am having trouble understanding this regular expression. Any help on this
is greatly appreciated.

open FILE, "xyz";
while (<FILE>)
{
undef($regexp_var);
($regexp_var) = ($_ =~
/("(\"|[^"])+")/);
s/("(\"|[^"])+")// if (defined
$regexp_var);
}
What does " do. (Quotes) " does not require blackslash but here it is used
with blackslash. What does this do.

Shilpa




Can you give us a little more context? Where did you get this from?
what it the script it's part of supposed to do?

The thing that jumps immediately to mind are 1) it was originally a
one-liner, and these are shell escapes, 2) it's a deliberate
obfuscation from perlmonks or someplace similar, 3) the original
delimiter was something else, and these are all literal backslashes,
or 4) the person who did this wasn't a very good coder, or was used to
using sed.

Actually 4 is obviously true, unless this is a deliberate obfuscation:
why perform the match and then the substition if the match is
successful? Just using s/// would have been more than adequate: it
can't substitute if it doesn't match.

Right now, it just looks like a really awkward way to delete a windows
path. Where *did* you dig this up?

-- jay
--------------------
daggerquill [at] gmail [dot] com
http://www.tuaw.com
http://www.dpguru.com
http://www.engatiki.org


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.