import yaml
 
 from lftools.nexus import Nexus
+from lftools.nexus import util
 
 log = logging.getLogger(__name__)
 
 
     def build_repo(repo, repoId, config, base_groupId):
         log.info('-> Building for {}.{} in Nexus'.format(base_groupId, repo))
-        groupId = '%s.%s' % (base_groupId, repo)
-        target1 = '^/%s/.*' % groupId.replace('.', '[/\.]')
-        target2 = '^/%s[\.].*' % groupId.replace('.', '[/\.]')
+        groupId = '{}.{}'.format(base_groupId, repo)
+        target = util.create_repo_target_regex(groupId)
 
         if 'extra_privs' in config:
             extra_privs = config['extra_privs']
 
         create_nexus_perms(
             repoId,
-            [target1, target2],
+            [target],
             settings['email_domain'],
             config['password'],
             extra_privs)
 
--- /dev/null
+# -*- code: utf-8 -*-
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+"""Utility functions for Nexus."""
+
+__author__ = 'Thanh Ha'
+
+import logging
+
+log = logging.getLogger(__name__)
+
+
+def create_repo_target_regex(group_id):
+    """Create a repo_target for Nexus use."""
+    return '^/{}/.*'.format(group_id.replace('.', '[/\.]'))
 
--- /dev/null
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+"""Test nexus command."""
+
+import re
+
+import pytest
+
+from lftools.nexus import util
+
+
+def test_create_repo_target_regex():
+    """Test create_repo_target_regex() command."""
+
+    odlparent = util.create_repo_target_regex('org.opendaylight.odlparent')
+    odlparent_regex = re.compile(odlparent)
+    assert odlparent_regex.match(
+        '/org/opendaylight/odlparent/odlparent'
+        '/4.0.0-SNAPSHOT/odlparent-4.0.0-20180424.132124-69.pom'
+    )
+
+    honeycomb = util.create_repo_target_regex('org.opendaylight.honeycomb.vbd')
+    honeycomb_regex = re.compile(honeycomb)
+    assert honeycomb_regex.match(
+        '/org/opendaylight/honeycomb/vbd/odl-vbd'
+        '/1.4.0-SNAPSHOT/odl-vbd-1.4.0-20180422.024456-12-features.xml'
+    )
+
+    mso = util.create_repo_target_regex('org.openecomp.mso')
+    mso_regex = re.compile(mso)
+    assert mso_regex.match(
+        '/org/openecomp/mso/'
+        '1.1.0-SNAPSHOT/mso-1.1.0-20170606.171056-26.pom'
+    )
+
+    dcaegen2 = util.create_repo_target_regex('org.onap.dcaegen2')
+    dcaegen2_regex = re.compile(dcaegen2)
+    assert dcaegen2_regex.match(
+        '/org/onap/dcaegen2/'
+        '1.2.0-SNAPSHOT/dcaegen2-1.2.0-20180403.182529-10.pom'
+    )
+
+    vpp = util.create_repo_target_regex('io.fd.vpp')
+    vpp_regex = re.compile(vpp)
+    assert vpp_regex.match('/io/fd/vpp/jvpp/16.06/jvpp-16.06.jar')