简体   繁体   English

ms excel中的正则表达式

[英]Regular Expression in ms excel

How can I use regular expression in excel ?如何在excel中使用正则表达式?

在此处输入图片说明

In above image I have column A and B .在上图中,我有A列和B列。 I have some values in column A .我在A列中有一些值。 Here I need to move data after = in column B .在这里,我需要在B列中的=之后移动数据。 For eg here in 1st row I have SELECT=Hello World.例如,在第一行,我有 SELECT=Hello World。 Here I want to remove = sign and move Hello world in column B .在这里,我想删除=符号并将Hello world移动到B列中。 How can I do such thing?我怎么能做这样的事情?

Stackoverflow has many posts about adding regular expressions to Excel using VBA. Stackoverflow 有很多关于使用 VBA 向 Excel 添加正则表达式的帖子。 For your particular example, you would need VBA to actually move a substring from one cell to another.对于您的特定示例,您需要 VBA 才能子字符串从一个单元格实际移动到另一个单元格。

If you simply want to copy the substring, you can do so easily using the MID function:如果您只想复制子字符串,可以使用MID函数轻松完成:

=IFERROR(MID(A1,FIND("=",A1)+1,999),A1)

在此处输入图片说明

I used 999 to ensure that enough characters were grabbed.我使用 999 来确保抓取了足够的字符。

IFERROR returns the cell as-is if an equals sign is not found.如果未找到等号, IFERROR将按原样返回单元格。

To return the portion of string before the equals sign, do this:要返回等号之前的字符串部分,请执行以下操作:

=LEFT(A1,FIND("=",A1&"=")-1)

In this case, I appended the equals sign to A1, so FIND won't return an error if not found.在这种情况下,我将等号附加到 A1,因此如果未找到FIND将不会返回错误。

You can use the Text to Column functionality of MS-Excel giving '=' as delimiter.您可以使用 MS-Excel 的 Text to Column 功能,将 '=' 作为分隔符。

Refer to this link: Chop text in column to 60 charactersblocks请参阅此链接:将列中的文本裁剪为 60 个字符块

You can simply use Text to Column feature of excel for this:您可以简单地使用 Excel 的 Text to Column 功能:

Follow the below steps : 
1) Select Column A.
2) Goto Data Tab in Menu Bar.
3) Click Text to Column icon.
4) Choose Delimited option and do Next and then check the Other options in delimiter and enter '=' in the entry box.
5) Just click finish.

Here are URL for Text to Column :http://www.excel-easy.com/examples/text-to-columns.html这里是文本到列的 URL:http ://www.excel-easy.com/examples/text-to-columns.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM