Re: Extracting Text from the right
- From: "Harlan Grove" <hrlngrv@xxxxxxx>
- Date: 8 Jul 2005 11:20:32 -0700
L Ellis wrote...
>Am looking for some help writing an equation to extract from the right of a
>string.
....
>What I want to do is write two equations:
>
>1) To extract to the right of the last "."
>2) To extract to the left of the last "."
....
Others have already responded with the standard approaches. I'd modify
the approach Ron Coderre took. Define a name like seq referring to the
formula
=ROW(INDIRECT("1:1024"))
Then use regular (nonarray) formulas like
1. =MID(A1,LOOKUP(2,1/(MID(A1,seq,1)="."),seq)+1,1024)
2. =LEFT(A1,LOOKUP(2,1/(MID(A1,seq,1)="."),seq)-1)
Another approach involves VBA. VBA can make use VBScript regular
expressions. Using the Subst function from
http://groups-beta.google.com/group/microsoft.public.excel.work***.functions/msg/9d74d1d78a685f59
(or http://makeashorterlink.com/?J17D21B3B ), you could use formulas
like
1. =subst(A1,".+\.","")
2. =subst(A1,"\.[^.]*$","")
[Excel isn't a good text processing tool. Regular expressions are the
most powerful text parsing tools developed to date. If you do this a
lot or your parsing tasks become more complicated, regular expressions
earn their keep.]
Finally, if all your parsing are domain names, splitting off top level
domain qualifiers, I believe the longest ones are 4 chars and the
shortest 2 chars. Unless there are domain names with a single char
immediately before the top level qualifier, e.g., www.x.us (which I
believe aren't allowed), all you need to look at are the last 5
characters in the string.
1. =RIGHT(A1,5-FIND(".",RIGHT(A1,5)))
2. =LEFT(A1,LEN(A1)-6+FIND(".",RIGHT(A1,5)))
.
- Follow-Ups:
- Re: Extracting Text from the right
- From: Ron Coderre
- Re: Extracting Text from the right
- References:
- Extracting Text from the right
- From: L Ellis
- Extracting Text from the right
- Prev by Date: Quick Little Function Help...
- Next by Date: using sumif formula: but requiring satisfying 2 if statements
- Previous by thread: Re: Extracting Text from the right
- Next by thread: Re: Extracting Text from the right
- Index(es):