简体   繁体   中英

Notepad++ regular expression replacement for mixed characters

Please, help me to write a regular expression for this kind of text in Notepad

I have a text with mixed russian and german sentences and words, and I need to insert before a sentence in russian tag <"RUSSIAN"> and before a sentence in german tag <"GERMAN"> . Like this:

INPUT:

Текст на русском, раз два три, german text - русский текст: german text - some other german text русский текст = еще русский текст. Длинный текст на русском. A long text on german

OUTPUT:

<"RUSSIAN">Текст на русском, раз два три, <"GERMAN">german text - <"RUSSIAN">русский текст: <"GERMAN">german text - some other german text <"RUSSIAN">русский текст = еще русский текст. Длинный текст на русском. <"GERMAN">A long text on german

I guess it could be done somehow by searching

cyrillics characters like "А,а,Б,б,В,в,Г,г,Д,д,Е,е,Ё,ё,Ж,ж,З,з,И,и,Й,й,К,к,Л,л,М,м,Н,н,О,о,П,п,Р,р,С,с,Т,т,У,у,Ф,ф,Х,х,Ц,ц,Ч,ч,Ш,ш,Щ,щ,Ъ,ъ,Ы,ы,Ь,ь,Э,э,Ю,ю,Я,я"

and german characters like "A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,A,a,O,o,U,u,?"

Punctuation & numbers make this a bit iffy but you can match any Cyrillic character & capture until a latin character;

Find: ([А-я].+?)([az])
Replace with: <ru>\\1</ru>\\2

Then the other language is between </ru> and <ru> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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