removing leading character from left,right a string

  • Follow


Hello,
I need to remove a space on the right and left of a string
name =3D "                                            =F4         "
    #line 5
   for (ix1=3D1;ix1<2;ix1++) getline ;
   name=3Dsubstr($0,0,52)
   name1=3Dgsub(/^ *| *$/, "",name)

In dos editor the space equal that character according to the font
used :  " " That is my code above but useless .

0
Reply ehabaziz2001 (345) 11/4/2007 9:18:24 PM


On 11/4/2007 3:18 PM, happytoday wrote:
> Hello,
> I need to remove a space on the right and left of a string
> name =3D "                                            =F4         "
>     #line 5
>    for (ix1=3D1;ix1<2;ix1++) getline ;
>    name=3Dsubstr($0,0,52)

Whatever the above is trying to do, using "getline" is almost certainy th=
e wrong
approach. Provide more info if you'd like help on doing it the right way.=


>    name1=3Dgsub(/^ *| *$/, "",name)
>=20
> In dos editor the space equal that character according to the font
> used :  " " That is my code above but useless .
>=20

gsub() doesn't return a string. You just need to use a character class:

    gsub(/^[[:space:]]*|[[:space:]]*$/,"",name)

Regards,

	Ed.

0
Reply Ed 11/4/2007 11:33:55 PM


1 Replies
924 Views

(page loaded in 0.116 seconds)

Similiar Articles:













7/23/2012 8:40:02 AM


Reply: