![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Parsing Link Attribute values with regular expressions Topic Summary: grabbing a line from a link attribute and detecting if it's invalid, including blank lines Created On: 13-Jun-2008 22:19 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
As part of a "Batch Link By Attribute" tool I'm trying to improve, I'd like to parse through Link Attributes (an attribute of Type "Text" that contains values compatible with DOORS native "Link by Attribute" tool) and create/delete links accordingly. I'd like the parsing of a Link Attribute (LA) to be more robust than DOORS' tool, which means I want to detect invalid entries (extra newline characters, spaces, non-numeric characters, etc), alert the user, but still process as much as is reasonable. I was originally grabbing lines with a look (see top part of attached code). However, I found that regular expressions, when used to grab lines of text will return true so long as it finds a matching line somewhere, even if it has to skip over several empty lines. This problem was partially solved by making sure that the start of the match was the first character of the string (line 17). However, I can't find a way to detect the final extra newline that comes after the "3" in my example of a LA value. To gain more accurate detection, I had to write the attached function "getLine". With this function, you pass it a string, and tell it where to start looking. It then grabs all the text up to the next newline or the end of the string. The index of this endpoint is returned via an argument passed by reference, "endex".
Can anyone think of how to accomplish this same task with regexps? I'm sure the regexp implementation i have in the top half of the code could be made more efficient with a Buffer and using the find() function. but either way, the problem of a regexp not finding an empty line is problematic. Jason |
|
![]() |
|
![]() |
|
Hi Jason,
I'm not entirely sure what you're trying to do, but attached are two methods to itterate through this string ignoring white space (space newline or tab) Hope it helps, Paul Howstan |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.