问题描述
我已经尝试了一段时间了,但是我自己找不到解决此问题的解决方案-好的,我对正则表达式使用非常陌生,但是非常有兴趣学习,希望有人能给我一些脑力食物...
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)
我要寻找的是两个不同的正则表达式-与在记事本++中查找和替换一起使用
1.仅将方括号之前的所有单词大写
2.像1号一样+添加html标签)
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标签位于错误的位置,现在正确!
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 \U\1
确保选择了正则表达式
第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 ++和正则表达式:如何大写字符串的特定部分/查找/替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!