os_grep


Searches for strings matching a regular expression pattern.

Finds all strings in the range [ begin , end ) that match the regular expression pattern , and copies them to out . Returns the number of matches found.

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/regalgo.h>

template< class InputIterator, class OutputIterator >
size_t os_grep
  (
  InputIterator begin,
  InputIterator end,
  OutputIterator out,
  const string& pattern
  );
  
Example <ospace/helper/examples/regexpr4.cpp>
#include <iostream>
#include <vector>
#include <ospace/helper.h>

void
fill( vector< string >& v )
  {
  v.push_back( "Systems<ToolKit> is portable." );
  v.push_back( "Web<ToolKit> is portable." );
  v.push_back( "Systems<ToolKit> is flexible." );
  v.push_back( "Thread<ToolKit> is flexible." );
  v.push_back( "Systems<ToolKit> is efficient." );
  v.push_back( "Network<ToolKit> is efficient." );
  v.push_back( "Systems<ToolKit> is fun." );
  v.push_back( "Helper<ToolKit> is fun." );
  }

void
main()
  {
  vector< string > v;
  fill( v );

  string x( "Systems" );
  cout << "Search for = " << x << endl;
  os_grep( v.begin(), v.end(), ostream_iterator< string >(cout, "\n"), x );
  cout << endl;

  x = "fun";
  cout << "Search for = " << x << endl;
  os_grep( v.begin(), v.end(), ostream_iterator< string >(cout, "\n"), x );
  }

Search for = Systems
Systems<ToolKit> is portable.
Systems<ToolKit> is flexible.
Systems<ToolKit> is efficient.
Systems<ToolKit> is fun.

Search for = fun
Systems<ToolKit> is fun.
Helper<ToolKit> is fun.


Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.