Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

regular expression question(s)

0 views
Skip to first unread message

inder...@yahoo.com

unread,
Apr 12, 2006, 6:53:50 PM4/12/06
to
Hello everyone I've got these regular expressions and need helping
understanding them: Can someone help me out with details of each
expression ? Thanks.

1. /<[^>]+>/ # matches <open ..>, <foo >, etc. ?
2. /<\/?[^>]+>/ # matches any open or close tag ?
3. s/<img[^>]*>/hello/gi; #what does exacly hello replace ?

Paul Lalli

unread,
Apr 12, 2006, 7:28:26 PM4/12/06
to
inder...@yahoo.com wrote:
> Hello everyone I've got these regular expressions and need helping
> understanding them: Can someone help me out with details of each
> expression ? Thanks.
>
> 1. /<[^>]+>/ # matches <open ..>, <foo >, etc. ?

the [ ] mean to match any of the characters contained within. When a ^
is the first character of one of these character classes, it means
"not". And then + means "one or more of the previous". So this
matches:
a less than, one-or-more not-greaterthans, a greater than.

> 2. /<\/?[^>]+>/ # matches any open or close tag ?

When trying to match a / inside a regular expression that uses / as the
delimiters, it is necessary to "escape" it, by preceding it with a
backslash. The ? means "0 or 1 of hte previous" So this matches:
less than, 0 or 1 slashes, one-or-more not-greaterthans, greater than.

> 3. s/<img[^>]*>/hello/gi; #what does exacly hello replace ?

hello replaces the entire match. Which in this case is:
less than, i, m, g, 0 or more not-greaterthans, greater than.

So that entire string, from the < to the >, is replaced by 'hello'

You would do well to read some documentation:
perldoc perlretut
perldoc perlre

Paul Lalli

Matt Garrish

unread,
Apr 12, 2006, 7:36:40 PM4/12/06
to

<inder...@yahoo.com> wrote in message
news:1144882430....@j33g2000cwa.googlegroups.com...

The last one switches <img> tags with the word hello. The other do what they
say, albeit poorly. You shouldn't try to parse markup languages with regular
expressions unless you can trust the input (and even then it's often a bad
idea).

I'd suggest a skim through perlretut, perlrequick and perlre if you don't
understand character classes or quantifiers.

Matt


inder...@yahoo.com

unread,
Apr 12, 2006, 8:14:17 PM4/12/06
to

Thanks for the help everyone. I tried running the perldoc perlre but
get the error "Superuser must not run /usr/bin/perldoc without security
audit and taint checks" ? what does this mean ?

Jim Gibson

unread,
Apr 12, 2006, 9:01:50 PM4/12/06
to
In article <1144887257....@v46g2000cwv.googlegroups.com>,
<"inder...@yahoo.com"> wrote:


> Thanks for the help everyone. I tried running the perldoc perlre but
> get the error "Superuser must not run /usr/bin/perldoc without security
> audit and taint checks" ? what does this mean ?
>

It means you are logged in as root and trying to do things that do not
require root privileges. This can be a security risk, so Perl doesn't
let you do it. Try logging in as a normal user.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

inder...@yahoo.com

unread,
Apr 12, 2006, 9:34:14 PM4/12/06
to
Thanks works if I'm signed in just as a normal user but NOT root....why
is that ?

inder...@yahoo.com

unread,
Apr 12, 2006, 9:36:12 PM4/12/06
to

Jürgen Exner

unread,
Apr 12, 2006, 9:38:59 PM4/12/06
to
inder...@yahoo.com wrote:
> I tried running the perldoc perlre but
> get the error "Superuser must not run /usr/bin/perldoc without
> security audit and taint checks" ? what does this mean ?

It means that you are not following standard security operation procedures.
Working as root when not needed is a blatant security hole about the size of
the Mediterranian Sea. There are larger ones, but not many.

Of course this has nothing to do with Perl.

jue


Jürgen Exner

unread,
Apr 12, 2006, 9:41:27 PM4/12/06
to
inder...@yahoo.com wrote:
> Thanks works if I'm signed in just as a normal user but NOT
> root....why is that ?

What works as normal user and not as root? Please quote appropriate
content -as has been customary for 2 decades- such that people have a chance
to know what you are talking about.

jue


inder...@yahoo.com

unread,
Apr 12, 2006, 10:32:41 PM4/12/06
to
Many thanks to all you. Regards

inder...@yahoo.com

unread,
Apr 12, 2006, 11:11:47 PM4/12/06
to
0 new messages