是否可以在rascal中的字符串上使用split()时保留文字分隔符?
例如,
split("/*", line)
我能够创建自己的分割功能。这不是完美的,但似乎可以解决我之前遇到的问题。
public list[str] splitString(list[str] fileLines)
{
list[str] splitList = [];
for(line <- fileLines)
{
if( /^<x:.*>\/\*<y:.*>$/ := line)
{
splitList = splitList + x;
splitList = splitList + "/*";
splitList = splitList + y;
}
else if(/^<x:.*>\*\/<y:.*>$/ := line)
{
splitList = splitList + x;
splitList = splitList + "*/";
splitList = splitList + y;
}
else
{
splitList = splitList + line;
}
}
return splitList;
}