s/-([bc])/-:$1/g; actually doesn't look for the whole string at all--[bc] is a character class, not a literal string.
This means that your regex translates to
when you wanted that second line to read "the string 'bc' (save this string in $1)".
The easy solution is to take those brackets out:
s/-(bc)/-:$1/g;and for what I'm guessing is the next step (multiple strings that could match), you can use
s/-(foo|bar|bc|whatever)/-:$1/g;But in fact you might be better off with tachyon's suggestion:
s/(?<=-)(?=foo|bar|baz)/:/g; #assuming you have 5.005 or betterThe longer but more rewarding solution is to take another couple of trips through perlre when you have a moment--regexen are not the fastest thing in the world to pick up (for us mere mortals, anyway) but they reward study very nicely. :-)
Your other question just needs the last argument to split:
and you're all set. Good luck!($first, $second) = split ' ', "a b c", 2;
Update: fixed boneheaded mistake in split (thanks, Hofmator!)
In reply to Re: Re: place holder
by ChemBoy
in thread place holder
by eyal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |