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: Capturing slices of a string
Topic Summary:
Created On: 17-Aug-2005 21:04
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 Tony Goodman, on Thursday, August 18, 2005 3:32 PM

Answer:
You can use the match function or start and end functions to extract strings that were matched by a regular expression.

if (line s1)
{
print(s1[match 1])
print(s1[start 1: end 1] "\n")
}
 17-Aug-2005 21:04
User is offline View Users Profile Print this message


Brian Jackson

Posts: 10
Joined: 2-Aug-2005

I have code parses through a string and captures/identifies a substring using the Regexp construct. Portion of the code looks like the following:
------------------------------------------------------------
Object o
string attrName = "Object Text" // This is the attribute to search
string findMe = "Figure "
Regexp line1 = regexp findMe"[0-9]+(.|-)[0-9]+\\b"
string s1
-
-
-
for o in current Module do {
    s1 = o.attrName ""
    if (line1 s1)
    {
      <some DXL code>
    }
}
--------------------------------------------------------------------------
In the "if (line1 s1)" section, I'm trying to capture anything in the s1 string that matches the regexp expression. Suggestions?
Report this to a Moderator Report this to a Moderator
 18-Aug-2005 12:20
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Answer Answer
You can use the match function or start and end functions to extract strings that were matched by a regular expression.

if (line s1)
{
print(s1[match 1])
print(s1[start 1: end 1] "\n")
}

-------------------------
Tony Goodman
http://www.smartdxl.com
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.