Re: Prepend + to search words
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Thu, 29 Mar 2007 11:44:26 -0700
Grant wrote:
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
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- Follow-Ups:
- Re: Prepend + to search words
- From: Grant
- Re: Prepend + to search words
- From: Dr.Ruud
- Re: Prepend + to search words
- References:
- Prepend + to search words
- From: Grant
- Re: Prepend + to search words
- From: Tom Phoenix
- Re: Prepend + to search words
- From: Grant
- Prepend + to search words
- Prev by Date: create gui
- Next by Date: Re: Prepend + to search words
- Previous by thread: Re: Prepend + to search words
- Next by thread: Re: Prepend + to search words
- Index(es):
Relevant Pages
|