• Yahoo!
  • My Yahoo!
  • Mail
  •      Make Y! your home page
Yahoo! Search
Do you have feedback/suggestions for the Pipes team? We want to hear from you!
View: Simple | Summary | Expanded
As: Threaded | Msg List
Page 1 of about 1   First | < Prev | Next > | Last
Messages in Topic
View messages rated: What's this?
Regex to uppercase the first letter of each word in a string     11-May-08 12:50 pm    
Hello,

I am trying to uppercase the first letter of each word in a text input from the user and to replace the " " by "_".
For example, if the user enters "You like Iron man" I would like to get "You_Like_Iron_Man". I think I should use a string regex module but I can't figure out what to replace with what...

http://pipes.yahoo.com/pipes/pipe.info?_...

Thanks if you can help me !
Rating :
 (No ratings)
Rate it:
awful/not related to \pooraveragegoodexcellent

Jeremy C

21/Male


View Messages

Ignore User

Report Abuse

Re: Regex to uppercase the first letter of each word in a string     11-May-08 03:44 pm    
To replace a space with an underscore you can use the String Replace module with the "every" option selected.

To uppercase the first letter of each word is a completely different kettle of fish. To a limited extent I think it's possible, but the process would be very convoluted.

It seems to me that your example pipe is a very artificial example. If you supplied a real example we might be able to suggest a reasonable solution.
Rating :
 (No ratings)
Rate it:
awful/not related to \pooraveragegoodexcellent

hapdaniel

58/Male
NA


View Messages

Ignore User

Report Abuse

Re: Regex to uppercase the first letter of each word in a string     11-May-08 06:30 pm    
Ok thanks !

My real example might involve some torrent sites among many others... and as the use of it might be questionnable I don't want anyone to feel bad about it :)
Rating :
 (No ratings)
Rate it:
awful/not related to \pooraveragegoodexcellent

Jeremy C

21/Male


View Messages

Ignore User

Report Abuse

Re: Regex to uppercase the first letter of each word in a string     12-May-08 08:38 am    
Fair enough.

I'll work on the basis that you want to filter on the string entered, so we have our "I like spaghetti" string. I've already mentioned the String Replace module, so then we have "I_like_spaghetti".
The feed has 3 items with the titles
I_Like_Spaghetti
I_Like_Spaghetti_Westerns
I_Like_Chips

If we want to select the first 2 items, then we can use a Filter module and the "Contains" operator on our string as it stands.

If we want to select only the first item, there is a little more work to do. Basically the idea is to convert the titles (or rather copies of them), to all uppercase, and do likewise for the input string and then use a filter on those. After the String Replace use a String Regex module with a rule to replace "(.*)" with "\U$1". With the feed use a Rename module to copy item.title to, say, "uptitle". After that use a String Replace module within a Loop, select item.uptitle for both input and result and use the same rule as before. We can then use a Filter module to filter item.uptitle using the "Is" operator.
Rating :
 (No ratings)
Rate it:
awful/not related to \pooraveragegoodexcellent

hapdaniel

58/Male
NA


View Messages

Ignore User

Report Abuse

View: Simple | Summary | Expanded
As: Threaded | Msg List
Page 1 of about 1   First | < Prev | Next > | Last