Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
Ygen
circle source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
Build 128
Build 129
Build 131
Latest
Options
Source code
#include <algorithm> #include <ranges> #include <vector> #include <https://raw.githubusercontent.com/codereport/blackbird/main/combinators.hpp> #include <fmt/core.h> #include <fmt/ranges.h> #include <range/v3/range/conversion.hpp> using namespace std::views; using namespace combinators; auto scan_left(auto rng, auto init, auto op) { return transform(rng, [first = true, acc = init, op](auto e) mutable { if (first) first = false; else acc = op(acc, e); return acc; }); } auto filter_out_html_tags(std::string_view sv) { return sv |> transform($, [](auto e) { return e == '<' or e == '>'; }) |> zip_transform(std::logical_or{}, $, scan_left($, true, std::not_equal_to{})) |> zip($, sv) |> filter($, [](auto t) { return not std::get<0>(t); }) |> values($) |> ranges::to<std::string>($); } auto filter_out_html_tags2(std::string_view sv) { return sv |> transform($, _phi(_eq('<'), _or_, _eq('>'))) |> zip_transform(_or_, $, scan_left($, true, _neq_)) |> zip($, sv) |> filter($, _b(_not, _fst)) |> values($) |> ranges::to<std::string>($); } int main() { fmt::print("{}\n", filter_out_html_tags ("<div>Hello <b>Italian C++!</b></div>")); fmt::print("{}\n", filter_out_html_tags2("<div>Hello <b>Italian C++!</b></div>")); return 0; }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree