Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
compile visual studio c++ online
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
#include <string> #include <regex> #include <iostream> int test_regex_search(const std::string& input,int*t) { std::regex rgx("(([:punct:]*)[[:alnum:]]+([:punct:]*))"); std::smatch match; if (std::regex_search(input.begin(), input.end(), match, rgx)) { std::cout << " matched = " << match[0] << " \n " ; *t+=(int)(match[0].second._Ptr-input.begin()._Ptr) ; return match[0].second-match[0].first; } else return (*t=0); } int main() { const std::string sentence = "ab cd ef"; int letters=0,words=0,ret=0,length=(int)(sentence.length()); do { letters+=test_regex_search(&sentence.at(ret),&ret); words+=!!ret; } while((ret!=0)&(ret<length)); std::cout << " letters= " << letters << " words= " << words; }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1.17 sec, absolute running time: 0.08 sec, absolute service time: 1.26 sec
edit mode
|
history
matched = ab matched = cd matched = ef letters= 6 words= 3