CadFrank Posted July 19, 2016 Share Posted July 19, 2016 Hi, I've got a string that contains "(Value)" and i'd like to count them. What functions whould i use? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 19, 2016 Share Posted July 19, 2016 Count occurrences or add values? Single string with multiple occurrences or multiple strings? Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 19, 2016 Author Share Posted July 19, 2016 Count the caracters between the Parenthese in a single string Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 19, 2016 Share Posted July 19, 2016 (vl-string-position (ascii "(") "aa(bbb)cccc") Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 19, 2016 Share Posted July 19, 2016 Or: (vl-string-search "(" "aa(bbb)cccc") Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 19, 2016 Author Share Posted July 19, 2016 (defun parPosition (string / PositionStart PositionEnd) (setq PositionStart (vl-string-position (ascii "(") string)) (setq PositionEnd (vl-string-position (ascii ")") string)) (setq Count (- PositionEnd PositionStart)) Count ) Like this Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 19, 2016 Author Share Posted July 19, 2016 How do I control an error of if block not selected return to the beginning? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 19, 2016 Share Posted July 19, 2016 (defun parPosition (string / PositionStart PositionEnd) (setq PositionStart (vl-string-position (ascii "(") string)) (setq PositionEnd (vl-string-position (ascii ")") string)) (setq Count (- PositionEnd PositionStart)) Count ) Like this Not quite. You should subtract 1 from count. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 19, 2016 Share Posted July 19, 2016 How do I control an error of if block not selected return to the beginning? You should start a new topic. And explain better. Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 19, 2016 Author Share Posted July 19, 2016 I did but in my other routine Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted July 20, 2016 Share Posted July 20, 2016 Try this once (vl-list->string (reverse (member 41 (reverse (member 40 (vl-string->list "aa(bbb)cccc")))))) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.