I have a str like this;
"B S <b.s@msoft.com>; J T <j.t@msoft.com>; A M <a.m@msoft.com>"
and i want to return to this format;
"b.s@msoft.com, j.t@msoft.com, a.m@msoft.com"
how i can do this?
str mail, a, mnew;
int b, c;
List strlist = new List(Types::String);
ListIterator iterator;
mail = "B S <b.s@msoft.com>; J T <j.t@msoft.com>; A M <a.m@msoft.com>";
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();
}
I do this with string runtime funtions. How can do it with regexp?
Please check below one of the possible examples with regular expressions:
TextBuffer textBuffer = new TextBuffer();
int pos, len;
str res;
;
textBuffer.setText("Brandon Smith <brandon.smith@msoft.com>; Jake Tyler <jake.tyler@msoft.com>; Amelia Miler <amelia.miler@msoft.com>");
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());