"t" value search

"t" value search

sudarsann
Advocate Advocate
362 Views
1 Reply
Message 1 of 2

"t" value search

sudarsann
Advocate
Advocate

I have a text with multiple tab spaces between words.

 

Ex: PLOT_NO"\t"STATUS"\t"LAND_USE"\t"LENGTH"\t"PLOT_DESC"\t"PLOT_TYPE"\t"WIDTH.

 

In above sentence there a tab ("\t") between the words. How can I get the "t" position value of first "\t", second "t" ....... and so on using lisp. 

 

Regards

Sudarsan

0 Likes
Accepted solutions (1)
363 Views
1 Reply
Reply (1)
Message 2 of 2

hmsilva
Mentor
Mentor
Accepted solution

@sudarsann wrote:

I have a text with multiple tab spaces between words.

 

Ex: PLOT_NO"\t"STATUS"\t"LAND_USE"\t"LENGTH"\t"PLOT_DESC"\t"PLOT_TYPE"\t"WIDTH.

 

In above sentence there a tab ("\t") between the words. How can I get the "t" position value of first "\t", second "t" ....... and so on using lisp. 

 

Regards

Sudarsan


Untested...

 

(setq str "PLOT_NO\tSTATUS\tLAND_USE\tLENGTH\tPLOT_DESC\tPLOT_TYPE\tWIDTH"
      len (strlen str)
      st  0
      lst nil
)
(while (and (< st len)
            (setq pos (vl-string-position (ascii "\t") str st))
       )
    (setq lst (cons pos lst)
          st  (1+ pos)
    )
)
(if lst
    (setq lst (reverse lst))
)

 

Hope this helps,
Henrique

EESignature

0 Likes