Capitalize the first letter of every word? - InfoPath Dev
in

InfoPath Dev

Capitalize the first letter of every word?

Last post 06-14-2012 11:15 AM by fhall. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-10-2011 04:21 PM

    Capitalize the first letter of every word?

    I've found the solution to capitilize the FIRST word of the text box -

    translate(substring("field", 1, 1), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), substring("field", 2, string-length("field") - 1)

    But what if you want to capitalize the first letter of EVERY word in the text box?

    I have a city text box that I want to do this with, so that San Diego will be correct, and not San diego. 

    Any thoughts?

    Thanks!

  • 04-11-2011 07:13 AM In reply to

    Re: Capitalize the first letter of every word?

    What if you also translate the first letter than comes after a space? You would need to use something like substring-after to locate that letter.
    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 04-13-2011 01:55 PM In reply to

    Re: Capitalize the first letter of every word?

    Any tips on how I would combine that with my existing formula?  Also, what if there is more than one space?

     

    Thanks!

  • 04-15-2011 05:26 AM In reply to

    Re: Capitalize the first letter of every word?

    I got it working with two words (one space) in the field. I'm attaching a sample form.

    Perhaps you can try to extend this to two spaces or more and let us know if you find a formula?

    Thanks!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 06-14-2012 11:15 AM In reply to

    • fhall
    • Not Ranked
    • Joined on 06-14-2012
    • Posts 2

    Re: Capitalize the first letter of every word?

    Thanks for the sample - very helpful!

    In trying to find a true Title Case ruleset, can anyone (Ernesto?) give an example of something like this?
    plain-text logic (apologies) might be:

    replace "letter.space.lower-case-letter" with "letter.space.upper-case-letter"

    I'm more familiar with RegularExpression, so maybe this isn't possible in InfoPath (of course, no code allowed).

    how about adding just one more iteration to this, allowing capitalization of 3 words.
    I'd appreciate a working example - i'm terrible with making/editing these.

    using the 2nd part of your example (capitalize 2nd word) as the starting point, how do we separate the next/3rd word group?

    concat(substring-before(., " "), " ", translate(substring(substring-after(., " "), 1, 1), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), substring(substring-after(., " "), 2, string-length(.) - 1))

     possible to have case sensitive substring-before?

    concat(substring-before(., " lowercase-letter"), ...

    or to find third word sequentially?

    concat(substring-before(., " * "), ...   *=non-space repeated 1+

    many thanks for your patience and all this sites previous assistences.

    cheers,

     

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.