Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
RegExpress
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//g++ 7.4.0 ///////////////////////////////////////////////////////////////////////////// //RegExpress //this code is created by Rezaul Hoque on July 05,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <string> #include <regex> #include <iterator> int main() { std::string a="It's Tuesday! Time for a walk!\n"; std::regex WC("(\\w+)"); auto startWc=std::sregex_iterator(a.begin(),a.end(),WC); auto endWc=std::sregex_iterator (); std::cout<<"There are "<<std::distance (startWc,endWc)<<" words.\n"; std::regex look("Tuesday"); std::regex_replace(std::ostreambuf_iterator<char>(std::cout),a.begin(),a.end(),look,"__"); std::cout<<std::regex_replace(a,look,"[$&]"); return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 10.3 sec, absolute running time: 0.99 sec, cpu time: 0.02 sec, memory peak: 5 Mb, absolute service time: 11,36 sec
edit mode
|
history
|
discussion
There are 7 words. It's __! Time for a walk! It's [Tuesday]! Time for a walk!