Forum Discussion

subhash_a_chand's avatar
subhash_a_chand
New Contributor
7 years ago

Camel Case in Snaplogic

How can we convert the string in Camel Case in mapper ?

7 Replies

  • petar_rajchinos's avatar
    petar_rajchinos
    New Contributor III

    Hi cstwart,

    In order to use the new features you should probably upgrade your snaplex to the newest version.

  • jovan_j's avatar
    jovan_j
    New Contributor III

    Hi cstwart,

    You could also use the following expression: “test upper case”.replace(/\b\w/g, chr => chr.toUpperCase())

    • cjhoward18's avatar
      cjhoward18
      Employee

      Sure, but in your example that is not really camel case. it should result in a string that looks like this:
      “testUpperCase”

      Also, the camelCase method will be able to convert all sorts of strings into camel case. not just ones seperated by spaces. for example:

      “foo–bar”.camelCase() → fooBar

      “foo**bar”.camelCase() ->fooBar

      so if the use case is for special characters as well as spaces, I’d use the camelCase method

      • jovan_j's avatar
        jovan_j
        New Contributor III

        Hi cjhoward18,

        To achieve this you could extend your expression: “test camel-case+&^%$#@!*to=upper”.replace(/\b\w/g, chr => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, “”)

    • subhash_a_chand's avatar
      subhash_a_chand
      New Contributor

      Hi cstwart,
      I found this documentation but looks like its not incorporated in mapper as we get “method not found error”.