RE: Nonquoted expression

"Jones, David G" <[email protected]> Fri, 16 Aug 2002 11:45:01 +0100
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <5158BC6D771ED3118D6200508B2C2722395C51@gbrxmsms01.bh.gbr.xerox.com>
This may not be the answer you're looking for but it seems to me that
there's a problem with the format of your property string.  In general a
name/value set has a strictly defined syntax (to make parsing easier!) and
it seems that the syntax you describe is very loose: quotes optional, values
delimited by space when spaces are allowed in values (and optional spaces
before the '='?).  This makes your job of parsing quite tricky.  Ideally I'd
suggest tightening the rules to use a specific delimiters for key/value sets
or making quotes mandatory (and hence not allowing them in values).

If you can do this you might find you've no need for regexes at all.  If you
can't, maybe ([A-Za-z]+?)= can help. It will find occurences of "word=",
with group 1 containing "word".  Check out the javadoc for
org.apache.oro.text.regex for a description of +?

hth 

Dave


-----Original Message-----
From: Srinivasan Krishnan [mailto:[email protected]]
Sent: 15 August 2002 23:18
To: [email protected]
Subject: Nonquoted expression


Hi 


Sorry for my limited knowledge in RegEXp. I could find a lot of Geeks in
Discussion forum. please teach me the below

My java RegExp is  "([a-z]+)\\s*=\\s*\"([^\"]+)\""   is the expression i use
to   extract all the  Key =  values pair in the string   

   face="Arial, Serif" size="+2" color="red " 

But how ever this approach fails when the value is not quoted  . when i use
RegExp    \\s*([a-z]+)\\s*=\\s*([^\\s]*)\\s* this works for unquoted String
values 
such as 

face="Arial, Serif" size=+2 color="red " 

 but fails when my input string is   

   face=Arial Serif size="+2" color="red " 



How to write a REGEXp such that accepts the unquoted values as well as space
in between the values.

regards,
srini SK