PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → [WD22] Help with Regex
[WD22] Help with Regex
Iniciado por Wahib Hassaini, jul., 19 2018 3:38 PM - 2 respostas
Publicado em julho, 19 2018 - 3:38 PM
Hello,

I'm having a hard time with regex.
I need to isolate parts with a certain color in a RTF field.
Here is my source :
Quote


{\
tf1\ansi\ansicpg1252\deff0\
ouicompat\deflang1033{\onttbl{\0\nil\charset0 Tahoma;}}

{\colortbl ;\
ed0\green0\lue0;\
ed64\green85\lue141;\
ed0\green30\lue196;}

{\*\generator Riched20 10.0.17134}\viewkind4\uc1

\pard\cf1 Elem1\cf2 Hello \cf3 Elem2\par

2nd Liane : \cf3 Elem3\cf2\par

\cf3 Elem4\cf2 3rd\cf3 Elem5\cf2 Line : \cf3 Elem6\cf2\par

4th Line : \cf1 Elem7\cf0\par

}

Here is my regex :
(?<=\\cf[13] ).*?(?=\\cf.)


It's working just fine on those sites :https://regex101.com/ , https://www.regextester.com/ , https://regexr.com/
But not in Windev...

Do you have an idea why?
Thank you.
Publicado em julho, 19 2018 - 3:52 PM
Hi Wahib,

probably because supported regex expressions in wlanguage are way less advanced than on these web sites.

You can certainly ask the support about the difference in behavior for a definite answer about it.

Best regards
Membro registado
34 mensagems
Popularité : +3 (3 votes)
Publicado em julho, 20 2018 - 2:27 PM
Hi,

check out these links:

https://forum.pcsoft.fr/fr-FR/pcsoft.us.windev/45571-wd18-need-help-with-regular-expression/read.awp
https://forum.pcsoft.fr/fr-FR/pcsoft.fr.windev/95095-expressions-regulieres-regex-cherche-remplace/read.awp

sText is string = [
{\
tf1\ansi\ansicpg1252\deff0\
ouicompat\deflang1033{\onttbl{\0\nil\charset0 Tahoma;}}

{\colortbl ;\
ed0\green0\lue0;\
ed64\green85\lue141;\
ed0\green30\lue196;}

{\*\generator Riched20 10.0.17134}\viewkind4\uc1

\pard\cf1 Elem1\cf2 Hello \cf3 Elem2\par

2nd Liane : \cf3 Elem3\cf2\par

\cf3 Elem4\cf2 3rd\cf3 Elem5\cf2 Line : \cf3 Elem6\cf2\par

4th Line : \cf1 Elem7\cf0\par

}
]

sRegex is string = "(?<=\\cf[13] ).*?(?=\\cf.)"
clMatches est un MatchCollection <- Regex.Matches(sText,sRegex)
POUR TOUT clMatch de clMatches
Trace(clMatch.value)
// POUR TOUT clGroup DE clMatch.groups
// Trace(tab + clGroup.value)
// FIN
FIN