Notepad++ 和正则表达式:如何大写字符串的特定部分/查找/替换 [英] Notepad++ and regex: how to UPPERCASE specific part of a string / find / replace

查看:26
本文介绍了Notepad++ 和正则表达式:如何大写字符串的特定部分/查找/替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了一段时间来完成这项工作,但我自己找不到解决此任务的方法 - 好的,我对正则表达式的使用非常陌生,但对学习很感兴趣,希望任何人都有给我一些脑力食品...

i've been trying for some time now to get this working, but i can't find a solution to this task myself - ok, i'm very new to regex-use but quite interested to learn, hope anybody has some brainfood for me...

我的文本字符串是这样的 - 没有数字...

my text-string is like this - without the numbers...

Word1 Word2 word3(括号中的一些单词)
Word1(括号中的一些单词)
word1, Word2(括号中的一些单词)

Word1 Word2 word3 (some words in brackets)
Word1 (some words in brackets)
word1, Word2 (some words in brackets)

的意思:不定数量的单词(有时只有一个,可能是 2 到 4 个,有时用逗号分隔)后跟圆括号中的字符串(括号中的值不应更改)

means: an indefinite number of words (sometimes just one, maybe 2 to 4, sometimes separated by commas) followed by a string in round brackets (the value in the brackets should not change)

我正在寻找的是两个不同的正则表达式 - 在记事本++中与 FIND 和 REPLACE 一起使用
<强> 1.括号前的所有单词只大写
2.like no.1 + 添加html-tags)

what i'm looking for is two different regexes - to use with FIND and REPLACE in notepad++
1. only uppercasing of all the words before the brackets
2. like no.1 + adding html-tags)

应该看起来像:1:

WORD1 WORD2 WORD3(括号中的一些单词)
WORD1(括号中的一些单词)
WORD1, WORD2(括号中的一些单词)

WORD1 WORD2 WORD3 (some words in brackets)
WORD1 (some words in brackets)
WORD1, WORD2 (some words in brackets)

和2:

第二个 html-tag 位于错误的位置,现在正确!

2nd html-tag was at the wrong position, now right!

%htmltag%WORD1 WORD2 WORD3%/htmltag%(括号中的一些单词)
%htmltag%WORD1%/htmltag%(括号中的一些单词)
%htmltag%WORD1, WORD2%/htmltag%(括号中的一些单词)

%htmltag%WORD1 WORD2 WORD3%/htmltag% (some words in brackets)
%htmltag%WORD1%/htmltag% (some words in brackets)
%htmltag%WORD1, WORD2%/htmltag% (some words in brackets)

希望有人可以帮助我 - 事先谢谢!

hope somebody could help me - thax a lot beforhand!

推荐答案

第 1 部分你可以使用

For part 1 you can use

Find:  ^(.*?)(?=()
Replace U1

确保选择了正则表达式

第 2 部分

Find: ^(.*?)((.*?))
Replace:%htmltag%1%/htmltag%2

需要

WORD1 WORD2 WORD3 (some words in brackets)
WORD1 (some words in brackets)
WORD1, WORD2 (some words in brackets)

并将其转换为

%htmltag%WORD1 WORD2 WORD3 %/htmltag%(some words in brackets)
%htmltag%WORD1 %/htmltag%(some words in brackets)
%htmltag%WORD1, WORD2 %/htmltag%(some words in brackets)

这篇关于Notepad++ 和正则表达式:如何大写字符串的特定部分/查找/替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆