简体   繁体   English

正则表达式在 Notepad++ 上搜索像 'cpt' => 这样的字符串

[英]Regexp to search for strings like 'cpt' => on Notepad++

I'm trying to build a list of array of mime types for PHP.我正在尝试为 PHP 构建一个 mime 类型数组列表。 I got a long list of mime types but I need to remove all the 'xxx' => upfront.我有一个很长的 mime 类型列表,但我需要预先删除所有'xxx' => How to detect them using regexp cos I tried '[\u][a-z0-9]' => and it didn't work.如何使用正则表达式检测它们因为我尝试'[\u][a-z0-9]' =>并且它没有用。

    'cpt' => 'application/mac-compactpro',
    'cpt' => 'application/x-compactpro',
    'cpt' => 'application/x-cpt',
    'crl' => 'application/pkcs-crl',
    'crl' => 'application/pkix-crl',
    'crt' => 'application/pkix-cert',
    'crt' => 'application/x-x509-ca-cert',
    'crt' => 'application/x-x509-user-cert',
    'csh' => 'application/x-csh',
    'csh' => 'text/x-script.csh',
    'css' => 'application/x-pointplus',

You may try the following find and replace, in regex mode:您可以在正则表达式模式下尝试以下查找和替换:

Find:    ^\s*'.*?'\s*=>\s*('.*?',?)$
Replace: $1

Demo演示

Try this.... Find: ^\s*'\w+' =>试试这个.... 查找: ^\s*'\w+' =>
Replace with: empty替换为: empty

在此处输入图像描述

Let's keep it simple.让我们保持简单。 You need to search for ^\s*'\w\w\w' =>您需要搜索^\s*'\w\w\w' =>

Don't forget to set the Search Mode to Regular Expression in the search dialog.不要忘记在搜索对话框中将搜索模式设置为Regular Expression

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

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