【问题标题】:Extracting text between each quotation marks from file in notepad++从记事本++中的文件中提取每个引号之间的文本
【发布时间】:2015-04-02 12:28:17
【问题描述】:

我的文件包含超过 2000 个摘要,其中包含超过 18000 个句子,以 tag 开头,以 tag 结尾。我想通过notepad++查找信息,我的文件视图如下:

<abstract>
<sentence>Activationofthe<conslex="CD28_surface_receptor"sem="G#protein_family_or_group"><conslex="CD28"sem="G#protein_molecule">CD28</cons>surfacereceptor</cons>providesamajorcostimulatorysignalfor<conslex="T_cell_activation"sem="G#other_name">Tcellactivation</cons>resultinginenhancedproductionof<conslex="interleukin-2"sem="G#protein_molecule">interleukin-2</cons>(<conslex="IL-2"sem="G#protein_molecule">IL-2</cons>)and<conslex="cell_proliferation"sem="G#other_name">cellproliferation</cons>.</sentence> 
<sentence>In<conslex="primary_T_lymphocyte"sem="G#cell_type">primaryTlymphocytes</cons>weshowthat<conslex="CD28"sem="G#protein_molecule">CD28</cons>ligationleadstotherapidintracellularformationof<conslex="reactive_oxygen_intermediate"sem="G#inorganic">reactiveoxygenintermediates</cons>(<conslex="ROI"sem="G#inorganic">ROIs</cons>)whicharerequiredfor<conslex="CD28-mediated_activation"sem="G#other_name"><conslex="CD28"sem="G#protein_molecule">CD28</cons>-mediatedactivation</cons>ofthe<conslex="NF-kappa_B"sem="G#protein_molecule">NF-kappaB</cons>/<conslex="CD28-responsive_complex"sem="G#protein_complex"><conslex="CD28"sem="G#protein_molecule">CD28</cons>-responsivecomplex</cons>and<conslex="IL-2_expression"sem="G#other_name"><conslex="IL-2"sem="G#protein_molecule">IL-2</cons>expression</cons>.</sentence>  
<sentence>Delineationofthe<conslex="CD28_signaling_cascade"sem="G#other_name"><conslex="CD28"sem="G#protein_molecule">CD28</cons>signalingcascade</cons>wasfoundtoinvolve<conslex="protein_tyrosine_kinase_activity"sem="G#other_name"><conslex="protein_tyrosine_kinase"sem="G#protein_family_or_group">proteintyrosinekinase</cons>activity</cons>,followedbytheactivationof<conslex="phospholipase_A2"sem="G#protein_molecule">phospholipaseA2</cons>and<conslex="5-lipoxygenase"sem="G#protein_molecule">5-lipoxygenase</cons>.</sentence>  
<sentence>Ourdatasuggestthat<conslex="lipoxygenase_metabolite"sem="G#protein_family_or_group"><conslex="lipoxygenase"sem="G#protein_molecule">lipoxygenase</cons>metabolites</cons>activate<conslex="ROI_formation"sem="G#other_name"><conslex="ROI"sem="G#inorganic">ROI</cons>formation</cons>whichtheninduce<conslex="IL-2"sem="G#protein_molecule">IL-2</cons>expressionvia<conslex="NF-kappa_B_activation"sem="G#other_name"><conslex="NF-kappa_B"sem="G#protein_molecule">NF-kappaB</cons>activation</cons>.</sentence>  
<sentence>Thesefindingsshouldbeusefulfor<conslex="therapeutic_strategies"sem="G#other_name">therapeuticstrategies</cons>andthedevelopmentof<conslex="immunosuppressants"sem="G#other_name">immunosuppressants</cons>targetingthe<conslex="CD28_costimulatory_pathway"sem="G#other_name"><conslex="CD28"sem="G#protein_molecule">CD28</cons>costimulatorypathway</cons>.</sentence>
</abstract>

我想提取引号之间的文本,或者换句话说,我想删除所有数据,除了整个文本中的双引号,例如我想要的输出是这样的

CD28_surface_receptor  G#protein_family_or_group   CD28   G#protein_molecule  
primary_T_lymphocyte   G#cell_type

我在 Find What 中使用了.*"(.*)".*,然后通过替换全部替换为\1。它只从每行的最后提取带有引号的文本,但我想从所有文档和每一行中提取,因为我的文件中有更多带有双引号的字符串。

【问题讨论】:

  • 为什么要发布重复的内容? stackoverflow.com/questions/29409502/…
  • 我被注销了,忘记了我的密码
  • 我的这个问题还没解决
  • 为什么要特别使用notepad++?你不能使用其他工具(grep/awk)吗?
  • 我还没用过这些工具

标签: regex notepad++


【解决方案1】:

您可以在查找内容中使用[^"]*"([^"]+)"[^"]*,并替换为\1\r\n

或者,要将它们用制表符分隔,请替换为 \1\t

【讨论】:

  • 谢谢,这对我很有用,我也有类似的问题。一个问题,如果我希望输出包含“引号”标记,我将如何更改正则表达式?编辑:使用 "\1"\r\n 工作,哇正则表达式是如此简单! ...
  • 要么将它们添加到它们应该在的替换字符串中,要么将它们移动到 (...) 捕获组中:[^"]*("[^"]+")[^"]*
  • 谢谢:D 我赞成这个问题,即使它有点英式(英式印度)我想问一个类似的问题,但这个可怜的家伙已经因为问了一个重复而受到了打击:P
  • Thnaks @WiktorStribiżew.. 它在第二种情况下工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-26
  • 2013-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-11
相关资源
最近更新 更多