Динамические строковые операции Dynamics AX в формате электронной почты - PullRequest
1 голос
/ 17 апреля 2020

У меня есть стр 1009 *

Я делаю это с помощью функций времени выполнения строки. Как это можно сделать с помощью регулярного выражения?

1 Ответ

3 голосов
/ 17 апреля 2020

Пожалуйста, проверьте ниже один из возможных примеров с регулярными выражениями:

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());

infolog

...