Split string at last (or fourth) occurence of “.” delimiter

我怕爱的太早我们不能终老 提交于 2020-01-17 03:49:19

问题


I like to delimit the string as follow

Given the following String :

Column 1    
10.80.111.199.1345
127.0.0.1.3279

I will like to delimit numbers after the last ".", which will get the follow output

 Column 1       Column 2               

10.1.12.5       1345
127.0.0.1       3279

I know excel has the delimitor function which allows me to delimit with specific symbol or through the fixed width. It does not seems to work for fixed width.

Is there any alternatives, rather than delimited with "." can concating back the strings on Column 1?


回答1:


If all of your values follow the same format you have described then you could use these formulas:

=LEFT(A1,LEN(A1)-5) returms "127.0.0.1"

=RIGHT(A1,4) returns "3279"

Otherwise, if it needs to be more dynamic then these formulas will work (Reference: Excel: last character/string match in a string)

=LEFT(A1,FIND("@",SUBSTITUTE(A1,".","@",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))-1)

returms "127.0.0.1"

=TRIM(RIGHT(SUBSTITUTE(A1,".",REPT(" ",99)),99))

returns "3279"



来源:https://stackoverflow.com/questions/25320396/split-string-at-last-or-fourth-occurence-of-delimiter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!