User Tools

Site Tools


vba:functions:rxlib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
vba:functions:rxlib [13.10.2016 11:04:16]
yaslaw
vba:functions:rxlib [13.10.2016 11:16:18]
yaslaw
Line 2: Line 2:
     version=1.0.0     version=1.0.0
     vdate=03.10.2016     vdate=03.10.2016
-    fname=udf_rxmatch.bas+    fname=lib_rxlib.bas
     ns=%NAMESPACE%     ns=%NAMESPACE%
     fpath=/​vba/​functions     fpath=/​vba/​functions
 </​const>​ </​const>​
-====== [VBA] rxMatch() ======+====== [VBA] rxMatch() / rxLokup() / rxReplace() ======
 Prüft ob ein Value auf ein Pattern passt. Die RegExp-Objekte werden gecached. Interessant für SQL Prüft ob ein Value auf ein Pattern passt. Die RegExp-Objekte werden gecached. Interessant für SQL
  
Line 69: Line 69:
 ===== rxLookup() ===== ===== rxLookup() =====
 ==== Definition ==== ==== Definition ====
-<​code>​Result = rxLookup(value [,pattern [,iPosition]])</​code>​+<​code>​Result = rxLookup(value [,pattern [,position]])</​code>​
 <code vb>​Public Function rxLookup( _ <code vb>​Public Function rxLookup( _
         ByVal iValue As Variant, _         ByVal iValue As Variant, _
Line 80: Line 80:
  
 ==== Beispiele rxLookup() ==== ==== Beispiele rxLookup() ====
-<​code ​vb>SELECT t.username, rxLookup(t.username,​ '/​(ruedi)/​i'​, -1) AS Ruedi+<​code ​sql>SELECT t.username, rxLookup(t.username,​ '/​(ruedi)/​i'​) AS Ruedi
 FROM myTable t FROM myTable t
 WHERE rxMatch(t.username,​ '/​(ruedi)/​i'​);​ WHERE rxMatch(t.username,​ '/​(ruedi)/​i'​);​
Line 88: Line 88:
 Hansruedi ​ | ruedi Hansruedi ​ | ruedi
 Hans-Ruedi | Ruedi Hans-Ruedi | Ruedi
-Ruedi      | Ruedi</​code>​+Ruedi      | Ruedi 
 + 
 +SELECT t.username,  
 + rxLookup(t.username,​ '/​(ns)?​([-\s]?​)(ruedi)/​i',​ -1) AS fund, 
 + rxLookup(t.username,​ '/​(ns)?​([-\s]?​)(ruedi)/​i',​ 0) AS treffer_0,​ 
 + rxLookup(t.username,​ '/​(ns)?​([-\s]?​)(ruedi)/​i',​ 1) AS treffer_1,​ 
 + rxLookup(t.username,​ '/​(ns)?​([-\s]?​)(ruedi)/​i',​ 2) AS treffer_2 
 +FROM myTable t 
 +WHERE rxMatch(t.username,​ '/​(ns)?​([-\s])?​(ruedi)/​i'​);​ 
 + 
 +username ​  | fund     | treffer_0 | treffer_1 | treffer_2 
 +-----------|----------|-----------|-----------|---------- 
 +Hansruedi ​ | nsruedi ​ | ns        |           | ruedi     
 +Hans-Ruedi | ns-Ruedi | ns        | -         | Ruedi     
 +Ruedi      | Ruedi    |           ​| ​          | Ruedi    
 +</​code>​
  
 ===== rxReplace() ===== ===== rxReplace() =====
 ==== Definition ==== ==== Definition ====
-<​code>​Result = rxReplace(value [,pattern [,iPosition]])</​code>​+<​code>​Result = rxReplace(value [,pattern [,replace]])</​code>​
 <code vb>​Public Function rxReplace( _ <code vb>​Public Function rxReplace( _
         ByVal iValue As Variant, _         ByVal iValue As Variant, _
Line 104: Line 119:
  
 ==== Beispiele rxReplace() ==== ==== Beispiele rxReplace() ====
-<​code ​vb>SELECT t.username, rxReplace(t.username,​ '/​(hans)([-\s]?​)ruedi/​i',​ '​$1$2Peter'​) AS Ruedi+<​code ​sql>SELECT t.username, rxReplace(t.username,​ '/​(hans)([-\s]?​)ruedi/​i',​ '​$1$2Peter'​) AS Ruedi
 FROM myTable t FROM myTable t
 WHERE rxMatch(t.username,​ '/​(ruedi)/​i'​);​ WHERE rxMatch(t.username,​ '/​(ruedi)/​i'​);​
vba/functions/rxlib.txt · Last modified: 30.01.2017 12:58:55 by yaslaw