如何在字符串中找到第二个元音后的字符 [英] How to find the character after second vowel in a string

查看:80
本文介绍了如何在字符串中找到第二个元音后的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为这个如何在EXCEL中的字符串中找到第二个元音后的字符?是有趣的,除了太广泛。

I thought this How to find the character after second vowel in a string in EXCEL? was interesting, other than being too broad.

加我已经回答了,但是太晚了。

Plus I'd answered it but was too late.

问题

例如,如果我的字符串是

For example if my string is


Happy Song

The Happy Song

输出应为


p。

p.

如果是空白,则显示Nothing

If it is a blank, then display "Nothing"

<可能的解决方案

possible solution

一种公式方法(礼貌 tikkaty )

= IF(A1<> 中,IFERROR(MID(A1,FIND( |,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A1), 一, | ), E, |)中, i, |), O, |), U, |),FIND( |,SUBSTITUTE(SUBSTITUTE( SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A1), 一, |), E, |)中, i, |), O, |), u 的,|))+ 1)+1,1),没有第二个元音找到),)

推荐答案

这是一个无正则符号的变体:

Here's a regex-free variant:

Function charTest(s As String) As String
    Dim i As Integer, j As Integer, r As String
    For i = 1 To Len(s)
        If UCase(Mid(s, i, 1)) Like "[AEIOU]" Then j = j + 1
        If j >= 2 Then Exit For
    Next i

    If j >= 2 And i < Len(s) Then r = Mid(s, i + 1, 1)
    If r = "" Then r = "Nothing"

    charTest = r
End Function

验证:

Sub test2()
    Debug.Print charTest("abcdefghijkl")
    Debug.Print charTest("Excellence")
    Debug.Print charTest("Animal")
    Debug.Print charTest("The guppy pond")
    Debug.Print charTest("The smallest bike")
    Debug.Print charTest("Shea")
End Sub




f

l

m

p

l

没有任何

f
l
m
p
l
Nothing

这篇关于如何在字符串中找到第二个元音后的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆