Oct 16, 2001 #1 billyb Technical User Nov 18, 2001 5 EU Hi I wonder if you can help? I want to replace the first two letters of a word with another. For example America would become BBerica I know this is a easy one but help great.
Hi I wonder if you can help? I want to replace the first two letters of a word with another. For example America would become BBerica I know this is a easy one but help great.
Oct 16, 2001 #2 raider2001 Technical User Apr 27, 2001 488 US The following will work. $string = s/^\w{2}/BB/; The 's' is the substitution operator. The syntax for this operator is: s/match/replace/ So for the match we have: The '^' is to match the beginning of the string. The '\w{2}' is to match exactly 2 word characters. This match is replaced with 'BB'. Hope this helps. Upvote 0 Downvote
The following will work. $string = s/^\w{2}/BB/; The 's' is the substitution operator. The syntax for this operator is: s/match/replace/ So for the match we have: The '^' is to match the beginning of the string. The '\w{2}' is to match exactly 2 word characters. This match is replaced with 'BB'. Hope this helps.
Oct 16, 2001 Thread starter #3 billyb Technical User Nov 18, 2001 5 EU Thanks for the Help Upvote 0 Downvote