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: special regexp (limited repetions)
Topic Summary:
Created On: 7-Jun-2006 17:54
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.
 7-Jun-2006 17:54
User is offline View Users Profile Print this message


Hubertus Grobbel

Posts: 58
Joined: 3-May-2005

Hi experts,

I have a problem, because I need a certain regular expression in the meaning rather of an assertion than for cutting a text out of a string.

I would like to check, whether a string begins with "ABC" and contains "DEF" and does not end with "DEF".
This shall be possible within one regexp.

So "ABCDEF" shall not match whereas "ABCDEFG" shall match.

My regexp I have found so far lets DEF occur more than once, so "ABCxDEFxDEFx" matches also, which is not desired.
^ABC.*(DEF)+[^(DEF)]$

Actually I need to be able to define the following (called limited repetition), which is apparently not supported by DOORS

^ABC.*(DEF){1}.+

Is there any workaraound?

so following testcases shall be applicable:
not ok: ABCxDEF and ABCxDEFxDEF
ok: ABCxDEFx

Any help appreciated, maybe it is so simple ... But stay as concrete as possible in your ansswers :-)

Tia, Regards
Hubertus
Report this to a Moderator Report this to a Moderator
 7-Jun-2006 19:57
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 206
Joined: 15-Jul-2005

Hubertus,

Why limit yourself to one regex?

Something like below would work:

//--Begin Code--

Regexp r1 = regexp "^ABC".*
Regexp r2 = regexp "*DEF*"
Regexp r3 = regexp "DEF$"

if (r1 myText) && (r2 myText)
{
if !(r3 myText)
{
//success code here.
}
}

//--End Code--

I am no regex guru, but that's what I would do in your situation.

-------------------------
Kevin Murphy
http://www.baselinesinc.com
The Requirements Management Experts

Edited: 7-Jun-2006 at 19:59 by Kevin Murphy
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.