替换所有非字母数字字符,包括通配符
我从 JvdV 答案中获取了这个漂亮的公式
=TRIM(CONCAT(IF(ISNUMBER(SEARCH(MID(A1,ROW(A$1:INDEX(A:A,LEN(A1))),1),"-./ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")),MID(A1,ROW(A$1:INDEX(A:A,LEN(A1))),1)," ")))
:公式用简单的空格“”替换任何非字母数字字符 (&^%]#$)。 我在公式中放入了一些例外(-./),但这并不是所有例外。 通配符怎么样?如何用这个公式过滤通配符(~*?)?
我想:好吧,我会使用FIND而不是SEARCH,一切都会正确,只需将小写和大写字母放入FIND索引中,如下所示: *"-./ 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"*
然后我想:但是,如果我不仅想保留数字和常规字母怎么办?如果我想保留所有变音符号怎么办,如下所示: "ÁÀşäǍĀàÅĄşẤẦẮẰǠǺǞẪẴẢşşẨẲẠḀẬẶĂÂḂɃƁ ḄḆĆĊĈČÇşḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘşşɆẾỀḖḔỄḜẺ
I take this beautiful formula from JvdV answer:
=TRIM(CONCAT(IF(ISNUMBER(SEARCH(MID(A1,ROW(A$1:INDEX(A:A,LEN(A1))),1),"-./ 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")),MID(A1,ROW(A$1:INDEX(A:A,LEN(A1))),1)," ")))
This formula replace any non-alphanumeric character (&^%]#$) with simple space " ".
I put in formula some exception (-./ ), but this is not all exceptions.
How about wildcards? How to filter wildcards (~*?) with this formula?
I think: Ok, I will use FIND instead of SEARCH and all will be right, just put lowercase and uppercase alphabet in the FIND index, like this: *"-./ 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"*
Then I think: But, what if I want to keep not only numeric and regular alphabet? What if I want to keep all diacritics, like this: "ÁÀȦÄǍĀÃÅĄȺẤẦẮẰǠǺǞẪẴẢȀȂẨẲẠḀẬẶĂÂḂɃƁḄḆĆĊĈČÇȻḈƇƆḊĎḐĐƊḌḒḎÐƉÉÈĖÊËĚĔĒẼĘȨɆẾỀḖḔỄḜẺȄȆỂẸḘḚỆÉÈÊËḞƑǴĠĜǦĞḠĢǤƓḢĤḦȞḨĦḤḪⱧÍÌİÏǏĬĪĨĮƗḮỈȈȊỊḬÍÌÏÎȷĴǰḰǨĶƘᶄḲḴⱩꝀꝂꝄĹĿĽⱢⱠĻȽŁḶḼḺḸꝈḾṀṂŃǸṄŇÑŅƝṆṊṈÑŊÓÒȮÔÖǑŎŌÕǪŐỐỒƟØṒṐṌȪỖṎǾȬǬỎȌȎƠỔỌỚỜỠỘỞỢÓÒÔÖÕØṔṖⱣƤƦŔṘŘŖɌⱤȐȒṚṞṜŚṠŜŠṤṦṢṨŞṪŤƬṬƮṰṮȾŢŦÚÙÛÜǓŬŪŨŮŲŰɄǗǛṸṺỦȔȖƯỤṲỨỪṶṴỮỬỰÚÙÛÜṼṾẂẀẆŴẄẈẊẌÝỲẎŶŸȲỸɎỶƳỴÝŹŻẐŽƵẒẔ"
Then lowercase and uppercase alphabet is too much for FIND index.
Ok, for SEARCH index is also too much, because function accept max. 255 length, but lets say we have only 200 characters in index (numbers, alphabet and some diacritics)
So, the question is available:
How to filter (replace with space) wildcards (~*?) with this kind of formula?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我读到这个问题时,存在一些问题:
SEARCH()
的第二个参数中包含超过 255 个字符;SEARCH()
的第二个参数中的文字通配符;绕过长度限制的一种方法是向
SEARCH()
提供一个选项数组,在本例中是一个由长度小于 255 的两个元素组成的数组:中的公式
C1
:我们在这里所做的是:
{abc;xyz}
来检查我们的字符,这是一个垂直数组{a,b,c }
。请注意半栏和逗号之间的区别。MMULT()
可以对其求和。这意味着如果在数组的两个元素中的任何一个中找到该字符,它将返回相同的字符。否则,一个空格。要可视化上述内容:
请记住,您使用的是 Excel 2019,这意味着您需要 CSE 输入此公式。不用说,在 ms365 中使用其动态数组功能,一切都会变得更加容易。
As I read this question there are a few problems:
SEARCH()
;SEARCH()
;One way around the length limit is to feed
SEARCH()
an array of options, in this case an array of two elements of a lenght of <255:Formula in
C1
:What we did here is:
{abc;xyz}
to check against our characters which was an vertical array{a,b,c}
. Note the difference between semi-column and comma.MMULT()
can sum. Meaning if the character was found in any of the two elements of the array it will return that same character. Otherwise, a space.MMULT()
too then.To visualize the above:
Remember, you are using Excel 2019 which means you need to CSE-enter this formula. Needles to say that all will be much easier in ms365 using its dynamic array functionality.