是否可以使用Eclipse的正则表达式搜索转换为小写并替换?

时间:2012-02-07 17:43:50

标签: regex eclipse

我试过'\ L',但它似乎不是它的语法的一部分,它的帮助没有提到任何可用的变换。

我知道我可以并且知道如何从命令行执行此操作,但是......

是否可以使用Eclipse的正则表达式搜索进行大小写转换并替换?

2 个答案:

答案 0 :(得分:44)

您可以分两步完成。首先,您以小写形式插入字母表。然后你只保留正确的信件:

reg expr 1:([A-Z])

替换1:abcdefghijklmnopqrstuvwxyz$1

reg expr 2:(a)bcdefghijklmnopqrstuvwxyzA|a(b)cdefghijklmnopqrstuvwxyzB|ab(c)defghijklmnopqrstuvwxyzC|abc(d)efghijklmnopqrstuvwxyzD|abcd(e)fghijklmnopqrstuvwxyzE|abcde(f)ghijklmnopqrstuvwxyzF|abcdef(g)hijklmnopqrstuvwxyzG|abcdefg(h)ijklmnopqrstuvwxyzH|abcdefgh(i)jklmnopqrstuvwxyzI|abcdefghi(j)klmnopqrstuvwxyzJ|abcdefghij(k)lmnopqrstuvwxyzK|abcdefghijk(l)mnopqrstuvwxyzL|abcdefghijkl(m)nopqrstuvwxyzM|abcdefghijklm(n)opqrstuvwxyzN|abcdefghijklmn(o)pqrstuvwxyzO|abcdefghijklmno(p)qrstuvwxyzP|abcdefghijklmnop(q)rstuvwxyzQ|abcdefghijklmnopq(r)stuvwxyzR|abcdefghijklmnopqr(s)tuvwxyzS|abcdefghijklmnopqrs(t)uvwxyzT|abcdefghijklmnopqrst(u)vwxyzU|abcdefghijklmnopqrstu(v)wxyzV|abcdefghijklmnopqrstuv(w)xyzW|abcdefghijklmnopqrstuvw(x)yzX|abcdefghijklmnopqrstuvwx(y)zY|abcdefghijklmnopqrstuvwxy(z)Z

替换2:$1$2$3$4$5$6$7$8$9$10$11$12$13$14$15$16$17$18$19$20$21$22$23$24$25$26

你可以像这样转换为大写:

reg expr 1:([a-z])

替换1:ABCDEFGHIJKLMNOPQRSTUVWXYZ$1

reg expr 2:(A)BCDEFGHIJKLMNOPQRSTUVWXYZa|A(B)CDEFGHIJKLMNOPQRSTUVWXYZb|AB(C)DEFGHIJKLMNOPQRSTUVWXYZc|ABC(D)EFGHIJKLMNOPQRSTUVWXYZd|ABCD(E)FGHIJKLMNOPQRSTUVWXYZe|ABCDE(F)GHIJKLMNOPQRSTUVWXYZf|ABCDEF(G)HIJKLMNOPQRSTUVWXYZg|ABCDEFG(H)IJKLMNOPQRSTUVWXYZh|ABCDEFGH(I)JKLMNOPQRSTUVWXYZi|ABCDEFGHI(J)KLMNOPQRSTUVWXYZj|ABCDEFGHIJ(K)LMNOPQRSTUVWXYZk|ABCDEFGHIJK(L)MNOPQRSTUVWXYZl|ABCDEFGHIJKL(M)NOPQRSTUVWXYZm|ABCDEFGHIJKLM(N)OPQRSTUVWXYZn|ABCDEFGHIJKLMN(O)PQRSTUVWXYZo|ABCDEFGHIJKLMNO(P)QRSTUVWXYZp|ABCDEFGHIJKLMNOP(Q)RSTUVWXYZq|ABCDEFGHIJKLMNOPQ(R)STUVWXYZr|ABCDEFGHIJKLMNOPQR(S)TUVWXYZs|ABCDEFGHIJKLMNOPQRS(T)UVWXYZt|ABCDEFGHIJKLMNOPQRST(U)VWXYZu|ABCDEFGHIJKLMNOPQRSTU(V)WXYZv|ABCDEFGHIJKLMNOPQRSTUV(W)XYZw|ABCDEFGHIJKLMNOPQRSTUVW(X)YZx|ABCDEFGHIJKLMNOPQRSTUVWX(Y)Zy|ABCDEFGHIJKLMNOPQRSTUVWXY(Z)z

替换2:$1$2$3$4$5$6$7$8$9$10$11$12$13$14$15$16$17$18$19$20$21$22$23$24$25$26

答案 1 :(得分:9)

嗯,我不认为这是可能的。 \ L甚至\ u似乎没有像我预期的那样工作(至少在Indigo中)。也许最好在eclipse之外做这个,然后刷新de workspace。

PS:如果你觉得无聊,你可以搜索它们并用户CTRL + SHIFT + Y和CTRL + SHIFT + X来改变这种情况:P