Statalist


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

Re: AW: st: AW: AW: string functions


From   Miranda Kim <[email protected]>
To   [email protected]
Subject   Re: AW: st: AW: AW: string functions
Date   Tue, 27 Oct 2009 14:02:35 +0000

Thank you Nick, that is helpful indeed.
Best wishes,
Miranda

Nick Cox wrote:
As I flagged yesterday in my last contribution to this thread, one kind
of solution -- and in at least one sense the best kind -- is to use
regular expressions (regex, in some quarters). It seems that you want code. Try foreach v of var * { local label : var label `v' local label = regexr("`label'", "\(.*\)", "") label var `v' "`label'" }
Stata documentation doesn't include a full self-contained guide to
regex, any more than it explains (e.g.) differential or integral
calculus that it uses. But the elements here all appear in any first
lesson on regex. The parentheses ( ) have syntactic roles, so they need
to be escaped with \ to indicate that you are looking for literal
parentheses. The other content .* means roughly that anything can occur
in between. The first occurrence of each substring matching that pattern
is replaced by an empty string.
I guess there are good tutorials on regex on the internet, but I haven't
searched. Nick [email protected]
Miranda Kim

Yes indeed I was after something that would work regardless of what was in the parentheses as I would have so many different types of units to consider.


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index