Author Topic: removing parenthesis from a list item  (Read 1515 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
removing parenthesis from a list item
« on: February 25, 2013, 03:41:37 PM »
last PIA queston for today...  :ugly:

I have a list item that has parenthesis
((12345))


if i convert it to string (which is what i want) i get
(12345)

how can i get rid of the parenthesis
to just be a string "12345"
or a list item 12345
either or will work for me

kruuger

  • Swamp Rat
  • Posts: 637
Re: removing parenthesis from a list item
« Reply #1 on: February 25, 2013, 05:00:54 PM »
last PIA queston for today...  :ugly:

I have a list item that has parenthesis
((12345))


if i convert it to string (which is what i want) i get
(12345)

how can i get rid of the parenthesis
to just be a string "12345"
or a list item 12345
either or will work for me
Code: [Select]
(itoa (caar (list (list 12345))))k.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: removing parenthesis from a list item
« Reply #2 on: February 25, 2013, 05:33:42 PM »
I thought I had seen something posted earlier:  :? (vl-string-trim "()" "((12345))")

I assume you have a bunch of these in a list. This will remove them from the sublists:

Code: [Select]
(mapcar 'car '((123) (456) (789)))
And take it one step further creating the strings:

Code: [Select]
(mapcar 'vl-princ-to-string (mapcar 'car '((123) (456) (789))))
« Last Edit: February 25, 2013, 06:00:26 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: removing parenthesis from a list item
« Reply #3 on: February 25, 2013, 06:59:58 PM »
More information needed I think.

If it really is only one item, and such item contains an integer, I would agree with kruuger and use:
Code: [Select]
(itoa (caar '((12345))))

andrew_nao

  • Guest
Re: removing parenthesis from a list item
« Reply #4 on: February 26, 2013, 08:51:47 AM »
thanks once again for the replies.

i got it figured out after i posted this