![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Unstable regular expression Topic Summary: Created On: 29-Sep-2003 18:52 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: Your regular expression did not match bCode in tests 1, 2, 4 and 5. You cannot rely on the results of the 'match' function if the regular expression did not match. Suggest you use something like: re = regexp "^([0-9]*)(-([A-Z]*)(-([0-9]*)-([0-9]*))?)?$" if (re bCode) { // Test if the regular expression matches field1 = bCode[match 1] field2 = bCode[match 3] field3 = bCode[match 5] field4 = bCode[match 6] if (field1 != "") print "\nField 1: " field1 [etc] } else { print "\nInvalid input" } The '?' metacharacter does not seem to be in the DXL documentation for DOORS 5.2 but it matches zero or one of the preceding regular expression. | |
![]() |
|
Your regular expression did not match bCode in tests 1, 2, 4 and 5. You cannot rely on the results of the 'match' function if the regular expression did not match. Suggest you use something like:
re = regexp "^([0-9]*)(-([A-Z]*)(-([0-9]*)-([0-9]*))?)?$" if (re bCode) { // Test if the regular expression matches field1 = bCode[match 1] field2 = bCode[match 3] field3 = bCode[match 5] field4 = bCode[match 6] if (field1 != "") print "\nField 1: " field1 [etc] } else { print "\nInvalid input" } The '?' metacharacter does not seem to be in the DXL documentation for DOORS 5.2 but it matches zero or one of the preceding regular expression. Edited: 30-Sep-2003 at 14:01 by Paul Worrall |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Unstable regular expression
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.