Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Twitter Message Sub-string Extraction?

From   Eric Booth <>
To   "<>" <>
Subject   Re: st: Twitter Message Sub-string Extraction?
Date   Mon, 13 Jun 2011 20:28:59 +0000

On Jun 13, 2011, at 2:56 PM, Richard Fairbanks wrote:
> I still have one issue due to another data element I thought I could
> handle. The tweets also contain URLs. They're a mix of letters and
> integers. Even using the same loops you provide doesn't work for them
> (i.e., replacing things like "@" and "#" with "http:\\" won't pick out
> the full web address.

Keep in mind that you can use things like "http:\\" or "ftp:\\" in the strpos()/subinstr() commands in the previous examples. E.g., 
input str129(test)
"test #testt blah"
split test
foreach v in varlist test* {
foreach j in file ftp http {
	replace url = `v' if strpos(`v', "`j'://")

I'm not a regex-pert ... but maybe you could get a Stata-friendly version of one of these to work:

I'd be interested in hearing back if you come up with a good statement to match urls.
I've got one that worked pretty well with matching email addresses if that is a concern as well 
	-- it's here on my webpage under the -validemail.ado- section:

- Eric
Eric A. Booth
Public Policy Research Institute
Texas A&M University

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index