Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Does -strpos()- return the second occurrence of a string?


From   Pedro Nakashima <nakashimapedrolist@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Does -strpos()- return the second occurrence of a string?
Date   Sun, 21 Apr 2013 00:38:10 -0300

Thank you

2013/4/20 Nick Cox <njcoxstata@gmail.com>:
> Replace the first temporarily by a mask of the same length.
>
> . di strpos("frogtoadfrog", "frog")
> 1
>
> . di strpos(subinstr("frogtoadfrog", "frog", "grog", 1), "frog")
> 9
>
> This works for variables too.
>
> See also -moss- (SSC) and
>
> http://www.stata-journal.com/article.html?article=dm0056
>
>
> Nick
> njcoxstata@gmail.com
>
>
> On 20 April 2013 15:54, Pedro Nakashima <nakashimapedrolist@gmail.com> wrote:
>> Dear users
>>
>> I'm looking for a way to identify the position of a string, which is
>> not the first.
>>
>> For example, when we use-strpos () - to find the underscore "_" in the word:
>>
>> ab_cd_ef
>>
>> The function strpos () will return 3. But I wanted to return the
>> position of the second occurrence, 6.
>>
>> Does anyone know a way to deal with this problem?
>>
>> Best regards,
>> Peter
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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