Excel 正确解读文本和输出的公式

Excel formula that deciphers text and outputs properly

有没有办法让 excel 阅读文本并破译它是否有某些 character/letters?

这是我的例子sheet

我正在寻找可以破译的东西 这些准则。 1.如果条目有/则输出 URL。 2. 如果条目不是 URL 并且只有数字 和特殊字符然后输出IP。 3.如果输入是 不是 URL 或 IP,并且有超过 1 个 dots/periods/decimals 然后输出HOST。如果进入 不是 URL、IP 或 HOST(或只有 1 dot/period/decimal) 然后输出 FQDN。

这是我正在寻找的示例

我试过使用以下这些:


=IF(LEN(A1)-LEN(SUBSTITUTE(A1,"/“,””))=1,"URL",IF(LEN(A1)-LEN(SUBSTITUTE(A1,”.”,""))=1,"FQDN"‚IF(LEN(A1)-LEN(SUBSTITUTE(A1,".",”"))>1,"HOST")))

这适用于读取 URL、HOST 和 FQDN; 但是,它将 IP 读取为 HOST。

我也用过


=IF(OR(ISNUMBER(SEARCH({"A","B","C",”D","E","F”,"G","H","I","J","K",”L”,"M",”N","O","P","Q”,"R","S","T","U","V","W",”X","Y","Z"},A1))),””,"IP")

如果一个条目包含字母,它就可以读取,如果没有,它会输出 IP。

有没有办法结合这些或简化我想做的事情?

谢谢!

可能的解决方案(使用 O365 测试):

=IFS(ISNUMBER(VALUE(LEFT(A1:A5)))=TRUE,"IP",LEN(A1:A5)-LEN(SUBSTITUTE(A1:A5,".",""))>1,"HOST",LEN(A1:A5)-LEN(SUBSTITUTE(A1:A5,"/",""))=1,"URL",LEN(A1:A5)-LEN(SUBSTITUTE(A1:A5,".",""))=1,"FQDN")

经典方式(B1):

=IF(ISERROR(SEARCH("/",A1))=FALSE,"URL",IF(ISERROR(VALUE(LEFT(A1)))=FALSE,"IP",IF(LEN(A1)-LEN(SUBSTITUTE(A1,".",""))>1,"HOST",IF(ISBLANK(A1)=TRUE,"","FQDN"))))

输出:

这会为您的示例生成所需的输出(至少)

=IF(COUNTIF(A1,"*/*"),"URL",IF(ISNUMBER(VALUE(SUBSTITUTE(A1,".",""))),"IP",IF(LEN(A1)-LEN(SUBSTITUTE(A1,".",""))>1,"HOST","FQDN")))