本文介绍了迅速删除Unicode U + 2018左单引号,例如'Ali to Ali的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从以下字符串中删除Unicode U + 2018左单引号-



Ghulam'Ali,'Ali Khel,'Ali Sher'Alaqahdari。



我要删除出现的'A || ‘a || ‘U ||

我尝试过

  var myString =索兹玛·奎拉 
var diacriticRemovedString = myString.folding(选项:.diacriticInsensitive,区域设置:Locale.current)
print(diacriticRemovedString)

,但不起作用。

解决方案

由于U + 2018字符似乎没有被视为变音符号,因此您可以简单地搜索此类字符并将其删除。



这里是Swift删除变音符号和以下特定引号的4个版本(在您原始问题中指定):

  var myString = Sozmah Qal' ah 
var diacriticRemovedString = myString.folding(选项:.diacriticInsensitive,语言环境:Locale.current).replacingOccurrences(of:',带有:)
print(diacriticRemovedString)

输出:


How to remove Unicode U+2018 LEFT SINGLE QUOTATION MARK from strings like -

Ghulam ‘Ali, ‘Ali Khel,‘Ali Sher ‘Alaqahdari.

I want to remove occurrences of ‘A || ‘a || ‘U || ‘u in a string to A a U u respectively.

I tried

var myString = "Sozmah Qal‘ah"
var diacriticRemovedString = myString.folding(options: .diacriticInsensitive, locale: Locale.current)
print(diacriticRemovedString)

but it doesn't work.

解决方案

Since the U+2018 character doesn't appear to be treated as a diacritic, you can simple search for such characters and remove them.

Here is the Swift 4 version (as specified in your original question) that removes diacritics and these specific quotation marks:

var myString = "Sozmah Qal‘ah"
var diacriticRemovedString = myString.folding(options: .diacriticInsensitive, locale: Locale.current).replacingOccurrences(of: "‘", with: "")
print(diacriticRemovedString)

Output:

这篇关于迅速删除Unicode U + 2018左单引号,例如'Ali to Ali的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 02:44