0
split() 함수에 여러 구분 기호를 사용할 수있는 방법은 무엇입니까? 구분 기호로 두 단어 이상을 사용하고 싶지만 그 방법이 확실하지 않습니다.vba의 여러 구분 기호 (단어)
c = Trim(t.value)
arr = Split(c, "hello" , "hi")
split() 함수에 여러 구분 기호를 사용할 수있는 방법은 무엇입니까? 구분 기호로 두 단어 이상을 사용하고 싶지만 그 방법이 확실하지 않습니다.vba의 여러 구분 기호 (단어)
c = Trim(t.value)
arr = Split(c, "hello" , "hi")
바꾸기를 사용하여 여러 단어를 먼저 바꿀 수 있습니다. 그런 다음 분할하여 사용할 수 있습니다.
당신이 같이 갈 수
mystring= Replace(mystring, "hello", "#")
mystring= Replace(mystring, "hi", "#")
mystring= Replace(mystring, "thanks", "#")
newstring= Split(mystring, "#")
은 다음과 같습니다
Option Explicit
Sub main()
Dim t As String
Dim arr As Variant, seps As Variant, sep As Variant
seps = Array("hello", "hi") '<--| define your seperators list
t = "hello i would hello like to hi split this string hello with multiple hello separators hi" '<--| string to split
t = " " & t & " " '<--| add trailing blank to catch possible "border" 'separators'
For Each sep In seps
t = Replace(t, " " & sep & " ", "|") 'turn all separators into one only
Next sep
t = Trim(t) '<--| remove trailing blanks
If Left(t, 1) = "|" Then t = Right(t, Len(t) - 1) '<--| remove any initial 'separator'
If Right(t, 1) = "|" Then t = Left(t, Len(t) - 1) '<--| remove any final 'separator'
arr = Split(t, "|")
End Sub
내가 분할 일단 전에 단어와 함께 구분 기호를 당길 수 있어야합니다. 돌아갈 길이 있습니까? – johndoe253
그것을 얻지 못했습니다. 설명 할 수 있니? – Techidiot
구분 기호를 가져 오려면 각각의 바꾸기 후에 "split"을 반복하십시오. – Stavm