[H-GEN] char inset

Bruce Campbell bc at humbug.org.au
Tue May 2 20:37:54 EDT 2000


[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics.  Please observe the list's charter.          ]

On Wed, 3 May 2000, Grant, Luke wrote:

lgrant> so what i need is a howto on the following in either bash or perl.
lgrant> 
lgrant> "B43" which is the contents of a string variable must become "B043" and i

bash:
	l1="`echo $input | cut -c -1`"
	l2="`echo $input | cut -c 2-`"
	output="${l1}0${l2}"
perl:
	$output = $input;
	$output =~ /^([A-Za-z])(\d\d)$/${1}0${2}/g;

Both are doing the same thing.  Use perl, as the regex is easier.

-- 
  Bruce.                                                         | VP/BOFH
  Infinite Monkeys.  Infinite Keyboards.  I see no Shakespeare.  |  HUMBUG
  Usenet may or may not be an implementation of RFC2795.         |     PAN


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list