LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How to find out the capital lettes from a word and replace it with the small letter

    Employee
    Posted 08-08-2013 23:21

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Sreya

    Hi,

    I have a table which has a column called Name.
    Now I would like to explain the scenario with an example.

    Suppose I have a Name in the format:
    "AlexBrown"

    I want to get the name as "Alex Brown"
    For that,what I understand is, I need to find out the next capital letter and then give a space before that.

    Can you please tell me how to do that.

    It might be something very simple but a lil help will be appreciated.

    Thanks,

    Sreya


  • 2.  RE: How to find out the capital lettes from a word and replace it with the small letter

    Employee
    Posted 08-09-2013 04:14

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: pdespot

    Hello, Sreya.

    You can use a filter node and the regexSubstitute function. That function will look for a regular expression pattern and substitute whatever you tell it. Assuming the name of your field is 'name', you can use the following command:

    newName = 'name'.regexSubstitute("([a-z])([A-Z])","$1 $2")
    emit newName

    That will look for any lowercase letter followed by any uppercase letter - that's the first argument of the function. When it finds that pattern, it stores what's between the first () as $1 - which in this case is the lowercase letter - and what's between the second () as $2. The second argument in the function tells it what to replace the match with. Here, we're just saying replace it with what is $1 (the lowercase letter), a space, and what's in $2 (the uppercase latter).

    -Pavel


  • 3.  RE: How to find out the capital lettes from a word and replace it with the small letter

    Employee
    Posted 08-09-2013 05:53

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Sreya

    Thanks a lot... it works fine...