Question: Is there any regular expression pattern to change this string

> 
> This is a mix string of üößñ and English. üößñ üößñ are Unicode words.
> 
> 
> 

to this?

> 
> This is a mix string of, üößñ, and English., üößñ üößñ, are Unicode words.
> 
> 
> 

Actually, I want to split English words and non-English words with comma.

Thanks.

Answer: 
It depends on whether you want a [**shallow** or **deep**](http://www.uow.edu.au/~lukes/TEXTBOOK/notes-cpp/oop-condestructors/shallowdeepcopy.html) copy. Assuming a deep copy, you need to be able to copy whatever's at the "leaves" hanging off a `TreeNode` object; so ideally the functionality should be in `TreeNode` (unless `Tree` is a friend class of `TreeNode` that you've designed to be deeply familiar with its implementation, which is often the case of course;-). Assuming something like...:

```
template <class Leaf>
class TreeNode {
  private:
    bool isLeaf;
    Leaf* leafValue;
    TreeNode *leftPtr, *rightPtr;
    TreeNode(const&Leaf leafValue);
    TreeNode(const TreeNode *left, const TreeNode *right);
  ...

```

then you could add to it a

```
  public:
    TreeNode<Leaf>* clone() const {
      if (isLeaf) return new TreeNode<Leaf>(*leafValue);
      return new TreeNode<Leaf>(
        leftPtr? leftPtr->clone() : NULL,
        rightPtr? rightPtr->clone() : NULL,
      );
    }

```

If `Tree` is taking care of this level of functionality (as a friend class), then obviously you'll have the exact equivalent but with the node being cloned as an explicit arg.
You can try something like (untested)

```

class Tree {

  TreeNode *rootPtr;
  TreeNode* makeTree(Treenode*);
  TreeNode* newNode(TreeNode* p)
  {
   TreeNode* node = new Treenode ;
   node->data = p->data ;
   node->left = 0 ;
   node->right = 0 ;
  }
  public:
  Tree(){}
  Tree(const Tree& other)
  {
   rootPtr = makeTree(other.rootPtr) ;
  }
  ~Tree(){//delete nodes}
};

TreeNode* Tree::makeTree(Treenode *p)
{
 if( !p )
 {
  TreeNode* pBase = newNode(p); //create a new node with same data as p
  pBase->left = makeTree(p->left->data);
  pBase->right = makeTree(p->right->data);
  return pBase ;
 }
 return 0 ;
}

```