regex - Xpath replace function, processing matches -


I am writing a function for the "title case" string e.g. "This is a title" for "This is a title." The following line does not work because the regex group reference is lost (either I agree). Is there an easy way to uppercase my matching letter in the replacement function?

  Replace ($ input, '\ b [az]', upper-case ('$ 0'))   

\ b Expression XML Schema is not part of regular expressions. It is only considered as character B, and therefore you match with B after any other character.

Your replacement string here is upper case ('$ 0') just $ 0 and so you replace the character (s) with it yourself Are there.

You can not do this by using the function - you need something like xsl: analysis-string, from XSLT , but it is not available in XQuery 1.0.

As far as I can tell the only way to solve it with a recursive function. If your separator is not required to be protected, a simple solution can be used to use tokens.

  Function declares local: xs: string {if (string-lang ($ arg = $) = 0) and then $ first word as title-case ($ arg as xs: string) Let: $ Tokenize ($ AGR, "\ s") [1] Let's give $ first: = substrings ($ AGR, 1, 1) returns (string-long ($ first-word) = 0) then concat ($ First, the local: title-case (object ($ ARG, 2)) and if ($ first-word = "a" (or :: or any other word that should not be capitalized :)) then conat ($ first word, Local: Title-of ($ $ AGR, string-latte ($ first-word) + 1) Other concette (upper-case ($ first), substring ($ first word, 2), local: title-case ($ ARG, string- You will also need to make sure that the first word of each title is capitalized even when a small word like "A" is lying ($ first-word) + (1- first-word) + 1))}}  

, But I leave it as a practice for the reader. / P>


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -