| 22 | } |
| 23 | |
| 24 | class StringConv{ |
| 25 | public: |
| 26 | typedef String result_type ; |
| 27 | StringConv( CharacterVector old_, CharacterVector new__): |
| 28 | nr(old_.size()), old(old_), new_(new__){} |
| 29 | |
| 30 | String operator()(String text) const { |
| 31 | for( int i=0; i<nr; i++){ |
| 32 | text.replace_all( old[i], new_[i] ) ; |
| 33 | } |
| 34 | return text ; |
| 35 | } |
| 36 | |
| 37 | private: |
| 38 | int nr ; |
| 39 | CharacterVector old ; |
| 40 | CharacterVector new_ ; |
| 41 | } ; |
| 42 | |
| 43 | // [[Rcpp::export]] |
| 44 | CharacterVector test_sapply_string( CharacterVector text, CharacterVector old , CharacterVector new_){ |
no outgoing calls