Denis Pleic wrote:
>
> Hi Perlers,
>
> I need some help with a regex I can't figure out.
>
> In short, I need to enclose all occurences of certain "label"
> strings in a text file into '^' marks.
>
> I.e., for example:
>
> "See SAY_PLEASE_TXT and SAY_HELLO_TXT."
>
> Those string codes *always* come in all caps, and with *at least*
> one underscore character.
>
> The strings in capitals (with underscores) refer to string codes,
> which should be enclosed in special '^' marks, so that the above
> example should be changed to:
>
> "See ^SAY_PLEASE_TXT^ and ^SAY_HELLO_TXT^."
>
> I've managed to find some clues in Perl Cookbook, and got some
> results with modified "all caps" recipe:
>
> s/[^\Wa-z0-9]+\_/^$1^/g
>
> but, instead of enclosing the label into carets, it *replaces* the
> found text - and, besides, it does not find the whole string. In
> short, the above produces:
>
> "See ^^TXT and ^^TXT."
>
> which is definitely NOT what I wanted :-)))
>
> So, if anyone has any ideas and suggestions, I'd be more than
> grateful...
$_ = "See SAY_PLEASE_TXT and SAY_HELLO_TXT.\n";
s/([A-Z]+_[A-Z_]+)/^$1^/g; # assumes no leading _ possible
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users