Skip to content

Commit

Permalink
feat : 강조 텍스트 분리 확장 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Jan 16, 2025
1 parent 56c2b9b commit bb8cde4
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ fun String.toValidUrlString(): String = runCatching {
this
}
}.getOrElse { this }

fun String.extractEmphasizedText(): Pair<String, String> {
val regex = Regex("`([^`]*)`") // 백틱으로 감싸진 텍스트를 찾는 정규 표현식
val matchResult = regex.find(this) // 첫 번째 매치를 찾음

return if (matchResult != null) {
val emphasizedText = matchResult.groupValues[1]
val remainingText = this.replaceFirst(regex, "").trim()
emphasizedText to remainingText
} else {
"" to this
}
}

0 comments on commit bb8cde4

Please sign in to comment.