本文整理汇总了Python中qgis.core.QgsStringReplacement.process方法的典型用法代码示例。如果您正苦于以下问题:Python QgsStringReplacement.process方法的具体用法?Python QgsStringReplacement.process怎么用?Python QgsStringReplacement.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsStringReplacement
的用法示例。
在下文中一共展示了QgsStringReplacement.process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReplace
# 需要导入模块: from qgis.core import QgsStringReplacement [as 别名]
# 或者: from qgis.core.QgsStringReplacement import process [as 别名]
def testReplace(self):
""" test applying replacements"""
# case insensitive
r = QgsStringReplacement('match', 'replace', False, False)
self.assertEqual(r.process('one MaTch only'), 'one replace only')
self.assertEqual(r.process('more then one MaTch here match two'), 'more then one replace here replace two')
self.assertEqual(r.process('match start and end MaTch'), 'replace start and end replace')
self.assertEqual(r.process('no hits'), 'no hits')
self.assertEqual(r.process('some exmatches here'), 'some exreplacees here')
self.assertEqual(r.process(''), '')
# case sensitive
r = QgsStringReplacement('match', 'replace', True, False)
self.assertEqual(r.process('one MaTch only'), 'one MaTch only')
self.assertEqual(r.process('one match only'), 'one replace only')
# whole word only, case insensitive
r = QgsStringReplacement('match', 'replace', False, True)
self.assertEqual(r.process('some exmatches here'), 'some exmatches here')
self.assertEqual(r.process('some match here'), 'some replace here')
self.assertEqual(r.process('some exmatches MaTch here'), 'some exmatches replace here')
self.assertEqual(r.process('some match maTCh here'), 'some replace replace here')
self.assertEqual(r.process('some -match. here'), 'some -replace. here')
self.assertEqual(r.process('match here'), 'replace here')
self.assertEqual(r.process('some match'), 'some replace')
# whole word only, case sensitive
r = QgsStringReplacement('match', 'replace', True, True)
self.assertEqual(r.process('some exmatches here'), 'some exmatches here')
self.assertEqual(r.process('some match here'), 'some replace here')
self.assertEqual(r.process('some exmatches MaTch here'), 'some exmatches MaTch here')
self.assertEqual(r.process('some match maTCh here'), 'some replace maTCh here')