.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OESmartsLexReplace

.. oe:function:: OESmartsLexReplace

   .. oe:language:: c++

      .. oe:api::

         bool OESmartsLexReplace(std::string& smarts,
                                 const std::vector<std::pair<std::string, std::string> >& bindings)

   .. oe:language:: python

      .. oe:api::

         OESmartsLexReplace(smarts: str, bindings: List[(name, definition)]) -> modsmarts: str

   Replaces all the instances of ``$varname`` in the :term:`SMARTS`
   pattern ``smarts`` with the variables as defined by the mapping in
   ``bindings``.

   .. oe:language:: c++ python

      The following code demonstrates how to use
      :oe:src:`SmartsLexReplace<SmartsLexReplace>`.

   .. oe:source:: SmartsLexReplace.cpp
      :language: c++
      :frag:     SNIPPET

   .. oe:source:: SmartsLexReplace.py
      :language: python
      :frag:     SNIPPET

   .. oe:language:: c++ python

      The output of the above code snippet is the following:

      .. code-block:: console

         SMARTS = c[$([$([F,Cl]),$([Br,I])])]
         Match to chlorobenzene


