Hi,

I was wondering if there is a regex function that just matches patterns 
rather than matches and replaces? I have a need to find numbers in a string 
where I return the number if the string contains a number, otherwise I want 
to return the variable as unbound.

Here is an example below. (Note I am calculating the local name as 
afn:localName doesn't work if the local name portion has numeric leading 
characters. Are leading numeric characters in a local name illegal?). 
Currently, if the regex doesn't find a match, it returns the input string. 
If I use the optional fourth parameter to say force the result to be an 
empty string, TBC throws an error (note that this only happens if the 
optional parameter is an empty string but works fine if I use a string of 
length 1 or more)

bind(fn:substring(str(?s), spif:indexOf(str(?s), "#") + 2 )as ?localname)
bind(spif:regex(?localname, "^\\D?(\\d+)([\\w -]*)", "$1") as ?name)

Examples of local name inputs are:
E4120-30       -> 4120
8500-TAGP    -> 8500
DENISON      -> No Match (unbound)

Regards,
Mark.


-- 
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary 
Network (EVN), TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en

Reply via email to