Re: Prepend + to search words



> 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?

- Grant
.



Relevant Pages

  • Re: DCL question (of the day)- null byte in string symbol
    ... I have pointed out that this code was just to show the bug, ... Subject: Re: DCL question - null byte in string symbol ... Lexical substitution is a possibility. ...
    (comp.os.vms)
  • Re: performance surprise -- why?
    ... On 25 Aug 2004, Anno Siegel wrote: ... >> string to a file and counted the lengths of the lines using a simple ... The substitution method must move parts of the ... > The results show indexing and global matching in the same ballpark, ...
    (comp.lang.perl.misc)
  • Re: performance surprise -- why?
    ... > CCCTAAACCCTAAACCCTAAACCCTAAACCTCTGAATCCTTAATCCCTAAATCCCTAAAT...(30MB string). ... The substitution method must move parts of the ... The results show indexing and global matching in the same ballpark, ... sub substitute { ...
    (comp.lang.perl.misc)
  • Re: DCL question (of the day)- null byte in string symbol
    ... The string isn't that long. ... Note that is 7 bits of the second character, 8 bits of ... Lexical substitution is a possibility. ... The fact that command verification reflects a truncated command line ...
    (comp.os.vms)
  • Re: Prepend + to search words
    ... I'd probably use an s/// (substitution) on the string. ... I just had a look at some docs matching "perl substitution variable" ...
    (perl.beginners)