我有这样的str;
"B S <[email protected]>; J T <[email protected]>; A M <[email protected]>"
而且我想返回此格式;
"[email protected], [email protected], [email protected]"
我该怎么做?
str mail, a, mnew;
int b,c;
List strlist=new List(Types::String);
ListIterator iterator;
mail = "B S <[email protected]>; J T <[email protected]>; A M <[email protected]>";
strlist = strSplit(mail,';');
iterator = new ListIterator(strlist);
while(iterator.more())
{
if(strcontains(iterator.value(), "<"))
{
b = strFind(iterator.value(), "<", 1, strLen(iterator.value()));
c = strFind(iterator.value(), ">", 1, strLen(iterator.value()));
info(strFmt("%1",subStr(strRem(iterator.value(),'>'),b+1,c)));
}
else
info(strFmt("%1",strLRTrim(iterator.value())));
iterator.next();
}
我使用字符串运行时功能来执行此操作。如何使用regexp?
请检查以下可能的示例之一:
TextBuffer textBuffer = new TextBuffer();
int pos, len;
str res;
;
textBuffer.setText("Brandon Smith <[email protected]>; Jake Tyler <[email protected]>; Amelia Miler <[email protected]>");
textBuffer.regularExpressions(true);
while (textBuffer.find(@'\<[a-z0-9.@]+\>', pos))
{
pos = textBuffer.matchPos();
len = textBuffer.matchLen();
res = (res == '') ? textBuffer.subStr(pos, len) : res + ', ' + textBuffer.subStr(pos, len);
pos++;
}
textBuffer.setText(res);
textBuffer.removeChar('<>');
info(textBuffer.getText());