【发布时间】:2020-05-06 23:39:59
【问题描述】:
我为模块 A 中的每个需求确定了 3-5 个关键字。每个关键字用逗号分隔。现在我想搜索模块B中的每个需求,看看它们中的哪些词与每个关键词匹配。
【问题讨论】:
我为模块 A 中的每个需求确定了 3-5 个关键字。每个关键字用逗号分隔。现在我想搜索模块B中的每个需求,看看它们中的哪些词与每个关键词匹配。
【问题讨论】:
不确定您在寻找什么。如果我将要提出的这些解决方案都不是您正在寻找的,您可能需要说明。
如果您尝试创建一个仅在当前视图中显示具有这些关键字的对象的过滤器,您可以通过首先转到过滤器(工具 > 过滤器 > 定义)然后选择高级按钮来创建高级过滤器出现的过滤器菜单的左下角。
此时您可以为过滤器创建自定义规则。我会为每个单词创建一个单独的规则,定义如下:
Attribute: Object Text
Condition: contains
Value: <insert word here>
Match Case: uncheck
Regular Expression: uncheck
然后选择添加按钮将规则添加到高级选项中的可用规则列表中。
此时,您可以在可用规则列表中选择多个规则,并且可以将这些规则与/或组合在一起,为您想要的视图创建自定义过滤器。
如果您尝试使用仅包含特定单词的对象创建自定义视图。
如果您正在讨论编写 DXL 代码以自动吐出包含特定单词的需求。您可以使用如下所示的内容:
Object o
String s
int offset, len
for o in entire (current Module) do
{
if (isDeleted(o)) continue
s = o."Object Text"""
if findPlainText(s, "<insert word here>", offset, len, false)
{
print identifier(o) // or replace this line with however you want to display object
}
}
希望这会有所帮助。干杯!
编辑:
要对逗号分隔的列表执行操作,一次一个,您可以使用带有某种搜索功能的 while 循环,一次一个地切断单词。
void processWord (string someWord, Module mTarget, Object oSource)
{
Object oTarget
string objID = identifier(oSource)
for oTarget in mTarget do
{
if (<someWord in oTarget Object Text>) // edit function as necessary to do this
{
if (oTarget."Exists""" == "")
oTarget."Exists" = objID
else
oTarget."Exists" = oTarget."Exists" "," objID
}
}
}
int offset, len
string searchCriteria
Module mSource = read("<path of source module>", true)
Module mTarget = edit("<path of target module>", true)
Object oSource
for oSource in mSource do // can use "for object in entire(m)" for all objects
{
if (oSource != rqmt) continue // create conditions specific to your module here
searchCriteria = oSource."Search Criteria"""
while (findPlainText(searchCriteria, ",", offset, len, false))
{
processWord(searchCriteria[0:offset-1], mTarget, oSource)
searchCriteria = searchCriteria[offset+1:]
}
}
processWord(searchCriteria, mTarget, oSource) // for last value in comma separated list
【讨论】: