Modify

Opened 13 years ago

Closed 13 years ago

#8510 closed defect (worksforme)

Regex not working properly

Reported by: chronos.hun@… Owned by: Richard Liao
Priority: normal Component: TracTicketValidatorPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description (last modified by Ryan J Ollos)

I've configure the trac.ini with the following:

[ticketvalidator]
validates = summary
summary.rule = [0-9]{1,10}[.][0-9]{1,6}
summary.tip = Please correct summary format
validates = cf_project
cf_project.rule = [A-Z]*[-][I][P][L][S]
cf_project.tip = Please correct project name (SOMETHING-IPLS)

I've tried the regex here: http://www.regexplanet.com/simple/index.html

Test Results
Regular Expression
Original Expression 	[0-9]{1,10}[.][0-9]{1,6}
as a Java string 	"[0-9]{1,10}[.][0-9]{1,6}"
Replacement 	
groupCount() 	0
Test 	Target String 	matches() 	replaceFirst() 	replaceAll() 	lookingAt() 	find() 	group(0)
1 	12.12 	Yes 			Yes 	Yes 	12.12
2 	a12.12 	No 	a 	a 	No 	Yes 	12.12
3 	1212 	No 	1212 	1212 	No 	No
4 	12.12a 	No 	a 	a 	Yes 	Yes 	12.12
5 	23PO-IPLS 	No 	23PO-IPLS 	23PO-IPLS 	No 	No
6 	0000001014.0000132 	No 	2 	2 	Yes 	Yes 	0000001014.000013
7 	0000001014.000013 	Yes 			Yes 	Yes 	0000001014.000013

So it should work. Could you have a look? Thank you,Chronos

Attachments (1)

trac.png (26.4 KB) - added by chronos.hun@… 13 years ago.
Regex right, in trac is not working.

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by chronos.hun@…

Attachment: trac.png added

Regex right, in trac is not working.

comment:1 Changed 13 years ago by Ryan J Ollos

Description: modified (diff)

comment:2 Changed 13 years ago by Richard Liao

Status: newassigned

When validate more than one fields, the config should like this:

[ticketvalidator]
validates = summary, cf_project
summary.rule = [0-9]{1,10}[.][0-9]{1,6}
summary.tip = Please correct summary format
cf_project.rule = [A-Z]*[-][I][P][L][S]
cf_project.tip = Please correct project name (SOMETHING-IPLS)

comment:3 Changed 13 years ago by chronos.hun@…

Resolution: worksforme
Status: assignedclosed

Working, sorry for the inconvenience. I'll check if the documentation has this note, or i was who slipped over it.

Thanks!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Richard Liao.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.