473,499 Members | 1,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

whats wrong with my reg expression ?

rex2=re.compile('^"(?P<value>[^]*)"$',re.M)

File "/usr/lib/python2.5/re.py", line 180, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.5/re.py", line 233, in _compile
raise error, v # invalid expression
sre_constants.error: unexpected end of regular expression

?
Jan 15 '07 #1
1 5866
Gert Cuykens wrote:
rex2=re.compile('^"(?P<value>[^]*)"$',re.M)

File "/usr/lib/python2.5/re.py", line 180, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.5/re.py", line 233, in _compile
raise error, v # invalid expression
sre_constants.error: unexpected end of regular expression

?
You probably want

rex2=re.compile('^"(?P<value>[\^]*)"$',re.M)

Because [] is a bracketed group and the ^ within a bracketed group is a
negation, but you have negated nothing before closing the group.
Alternatively:

rex2=re.compile('^"(?P<value>\^*)"$',re.M)

Would have the same meaning, avoiding the bracketed group altogether.

James
Jan 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2058
by: JJ | last post by:
Hi all, whats wrong with the following code: DateTime calcDate = new DateTime(); DateTime dDate = DateTime.Now; if (calcDate.DayOfWeek(dDate) != "Saturday") || (calcDate.DayOfWeek(dDate)...
1
1197
by: COHENMARVIN | last post by:
I am trying to use an regularexpression validator to match floating numbers. My expression doesn't work. Here it is: ValExpression = "(0|*|*\.*|0\.*)" The \. is supposed to match the decimal...
8
2211
by: Martin Jørgensen | last post by:
Hi, "C primer plus" p.382: Suppose we have this declaration: int (*pa); int ar1; int ar2; int **p2;
14
4345
by: nobrow | last post by:
Yes I know what lvalue means, but what I want to ask you guys about is what are all valid lvalues ... a *a a *(a + 1) .... What else?
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.