Re: Prepend + to search words
- From: emailgrant@xxxxxxxxx (Grant)
- Date: Thu, 29 Mar 2007 12:36:59 -0700
>> > Hello, how can I prepend a "+" character to each of the words in a
>> > string? For example, "big blue widgets" should be changed to "+big
>> > +blue +widgets".
>>
>> I'd probably use an s/// (substitution) on the string. Match a word,
>> replace it with the plus sign and the word. Have you tried that?
>
> Hi Tom,
>
> I just had a look at some docs matching "perl substitution variable"
> since the words in the string could be anything, but perl docs have a
> way of overwhelming me really quickly. Can you show me how?
$ perl -le'$_ = "big blue widgets"; print; s/(\w+)/+$1/g; print'
big blue widgets
+big +blue +widgets
Thanks guys, work perfectly.
- Grant
.
- References:
- Prepend + to search words
- From: Grant
- Re: Prepend + to search words
- From: Tom Phoenix
- Re: Prepend + to search words
- From: Grant
- Re: Prepend + to search words
- From: John W. Krahn
- Prepend + to search words
- Prev by Date: Re: Prepend + to search words
- Next by Date: Re: How does one get the difference between 2 dates/times and output in seconds?
- Previous by thread: Re: Prepend + to search words
- Next by thread: create gui
- Index(es):