|
Boost Users : |
Subject: Re: [Boost-users] boost::regex_replace problem
From: ÐлÑÑ (ilya_bindug_at_[hidden])
Date: 2014-04-04 04:10:50
--- ÐÑÑ
одное ÑообÑение ---
ÐÑ ÐºÐ¾Ð³Ð¾: "Steven Watanabe" < watanabesj_at_[hidden] >
ÐаÑа: 3 апÑÐµÐ»Ñ 2014, 21:24:39
AMDG
On 04/03/2014 09:18 AM, ÐлÑÑ wrote:
> Greetings everyone! My name is Ilya and i have such problem with boost::regex_replace : I want to process some text messages to find and replace with * swears there. I wrote regular expressions, this is an example of one of them: "([[:punct:]]|[[:space:]]|[[:digit:]]|^)(?:a)(?:[[:punct:]]|[[:space:]]|[[:digit:]])*(?:b)(?:[[:punct:]]|[[:space:]]|[[:digit:]])*(?:c)([[:punct:]]|[[:space:]]|[[:digit:]]|$)". The format string i used is: "$1***$2"
> Then i run boost::regex_replace() and it works almoust correctly, except one case: when i have message with abc's standing next to each other with one separator beetween them, like this: "abc abc", "--abc-abc--" etc. So i need to run boost::regex_replace() twice to process corectly such messages.
> Are there any other ways to solve this problem? Thank you for answers.
>
If I'm understanding correctly, you should be
able to use lookahead (?=) and/or lookbehind (?<=),
I've simplified it to use just \s, as a separator:
"(?:^|(?<=\\s))(?:a)\\s*(?:b)\\s*(?:c)(?:(?=\\s)|$)"
and then just use "***" as the format. (warning: untested)
In Christ,
Steven Watanabe
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
('binary' encoding is not supported, stored as-is)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net