Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Unstable regular expression
Topic Summary:
Created On: 29-Sep-2003 18:52
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Paul Worrall, on Tuesday, September 30, 2003 5:51 PM

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.
 30-Sep-2003 13:44
User is offline View Users Profile Print this message


Paul Worrall

Posts: 87
Joined: 30-Sep-2003

Answer 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.

Edited: 30-Sep-2003 at 14:01 by Paul Worrall
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.