Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Length for strings, ignoring SMCL tags


From   "Kieran McCaul" <kamccaul@meddent.uwa.edu.au>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Length for strings, ignoring SMCL tags
Date   Wed, 3 Dec 2008 06:31:02 +0900

Is this what you mean:

. di strlen(substr("{err}hello", strpos("{err}hello","}")+1,.))
5


______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Fax: (08) 9224 8009
email: kamccaul@meddent.uwa.edu.au
http://myprofile.cos.com/mccaul 
_______________________________________________
The fact that no one understands you doesn't make you an artist.

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Brian
Karfunkel
Sent: Wednesday, 3 December 2008 5:58 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: Length for strings, ignoring SMCL tags

Hello,

Is there a way to get the length of a string while ignoring any SMCL
tags in the string?

In other words, I have "{err}hello", and I want the length of "hello",
since the "{err}" tag doesn't affect the length as outputted.

I've tried the following:

strlen(`"`: display "{err}hello"'"')

and variations thereof, but nothing seems to work. If there is a
solution, it would also be helpful to know how it would treat "{col
30}hello" and "{space 20}hello", for example, in terms of whether the
columns/spaces that are inserted are counted in the length (i.e.
whether it is literally the number of characters of the line on the
screen as displayed or if it is just the length of the string you'd
get if you, say, -regexr-ed out all the tags in braces).

Thanks for the help,

Brian Karfunkel
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index