![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: special regexp (limited repetions) Topic Summary: Created On: 7-Jun-2006 17:54 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
special regexp (limited repetions)
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.