Hi Holger, I am actually looking to return the text in the group matches rather than test a string against a regex therefore the SPARQL builtin won't work for me in this case. I am going to use a workaround for now where the unmatched portion returns a known string such as "No Match". I can then test for this string to determine if I was able to extract the number or not.
Regards, Mark. Regards, Mark. On Wednesday, 13 June 2012 16:29:55 UTC+10, Holger Knublauch wrote: > > There is a SPARQL built-in for checking regexes: > > http://www.w3.org/TR/rdf-sparql-query/#funcex-regex > > On the local names question, I guess the URI splitting logic is buried > somewhere in W3C namespace standards. Jena usually implements them > correctly, so I guess local names cannot start with digits. Others on > this list or the Jena list may know more. > > Holger > > > > On 6/13/2012 15:59, Mark Colquhoun wrote: > > 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 > > -- 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
