Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove any trailing "-" 1

Status
Not open for further replies.

sabetik

IS-IT--Management
Nov 16, 2003
80
GU
My inout data are:2330019295 and 161006934583
if input data is 10 character then I get this 23300-19295-
if inout data is 12 then look like this 16100-69345-83
which is good How can get rid of the last "-" in 10 character input

fd4 = substr($0,21,12)
# Insert "-" after each group of 5 chars.
gsub( /...../, "&-", fd4 )
# Remove any trailing "-".
sub( /-$/, "", fd4 )
 
sub( /- *$/, "", fd4 )

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top