Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > regex

Reply
Thread Tools

regex

 
 
boris bass
Guest
Posts: n/a
 
      08-25-2003
the following is the text string i am trying to match


bgColor=#ffffff

and i constructed the following regular expr


while ( $content =~ /=\s*[^"]#\w{6}[^"]/ )


and it doesnt seem to be working


I am actually trying to match from the equal sign and rightward, i.e.
match equal sign followed by zero or more whitespaces followed by the
pound sign followed by exactly six alphanumerics and NOT QUOTED -

NOT QUOTED is the whole point of a match

any suggestions appriciated
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      08-25-2003
boris bass <(E-Mail Removed)> wrote:

> the following is the text string i am trying to match
>
> bgColor=#ffffff



> I am actually trying to match from the equal sign and rightward, i.e.
> match equal sign followed by zero or more whitespaces followed by the
> pound sign followed by exactly six alphanumerics and NOT QUOTED -
>
> NOT QUOTED is the whole point of a match



/=\s*#\w{6}/
or
/=\s*#\w{6}(?!")/


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      08-25-2003
boris bass wrote:
>
> the following is the text string i am trying to match
>
> bgColor=#ffffff
>
> and i constructed the following regular expr
>
> while ( $content =~ /=\s*[^"]#\w{6}[^"]/ )
>
> and it doesnt seem to be working
>
> I am actually trying to match from the equal sign and rightward, i.e.
> match equal sign followed by zero or more whitespaces followed by the
> pound sign followed by exactly six alphanumerics and NOT QUOTED -
>
> NOT QUOTED is the whole point of a match
>
> any suggestions appriciated



$ perl -le'
for ( q/bgColor=#ffffff/, q/bgColor="#ffffff"/, q/ bgColor = #ffffff /, q/ bgColor = "#ffffff" / ) {
print if /=\s*(?<!")#[[digit:]]{6}(?!")/;
}
'
bgColor=#ffffff
bgColor = #ffffff



John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
Eric J. Roode
Guest
Posts: n/a
 
      08-26-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(E-Mail Removed) (boris bass) wrote in news:65fcb898.0308250725.18cf440
@posting.google.com:

> the following is the text string i am trying to match
>
>
> bgColor=#ffffff
>
> and i constructed the following regular expr
>
>
> while ( $content =~ /=\s*[^"]#\w{6}[^"]/ )


The problem is that

[^"]

matches "exactly one character that is not a quote". So it requires one
non-quote character between the optional whitespace and the # symbol.

You really don't need the [^"] business. If you are matching on \w{6},
it'll match six word characters; any quotes would cause the match to fail
anyhow.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP0q5xmPeouIeTNHoEQKxWgCg49tuMBDtc2jBGlGlAq6k4E gPlFkAn1Gk
iXyn5MLSm3qvcw0y/ShqKMsy
=fIVV
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
String Pattern Matching: regex and Python regex documentation Xah Lee Java 1 09-22-2006 07:11 PM
Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 02:43 PM
Java regex imposture re: Perl regex compatibility a_c_Attlee@yahoo.com Java 2 05-06-2005 12:16 AM
perl regex to java regex Rick Venter Java 5 11-06-2003 10:55 AM



Advertisments