Help with Regex
Posted: 19 Oct 2017 11:57
Hi,
I´m very new to regular expressions, but a little things are working yet.
I have the following problem:
Text used - just a testing sample
(?s) search also over linefeed \n
find <group> in the text followed by at least 1 character greedy (.+?)
followed by </group>
So far so good.
the result is
What am I doing wrong?
thanks,
regards,
I´m very new to regular expressions, but a little things are working yet.
I have the following problem:
Text used - just a testing sample
Regex used:<?xml version='1.0' encoding='UTF-8'
<notificationIconType>BUILTIN</notificationIconType>
<notificationIcon>FLASH</notificationIcon>
<customNotificationIcon></customNotificationIcon>
<title></title>
<message></message><group></group>
<sound>false</sound>
<largeIconEnabled>
<largeIcon></largeIcon>
<group></group><group>_in Arbeit</group>
<isGroupSummary>false</isGroupSummary>
<all>false</all>
<group>_in Arbeit</group>
</data>
As far as I understand(?s)<group>(.+?)</group>
(?s) search also over linefeed \n
find <group> in the text followed by at least 1 character greedy (.+?)
followed by </group>
So far so good.
the result is
if I change the regex tomatches(text, '(?s)<group>(.+?)</group>', groups)
--> false
findAll(text, '(?s)<group>(.+?)</group>')
--> [<group></group>
<sound>false</sound>
largeIconEnabled>
<largeIcon></largeIcon>
<group></group>, <group>_in Arbeit</group>, <group>_in Arbeit</group>]
findAll(text, '(?s)<group>(.+?)</group>', true)
--> [[<group></group>
<sound>false</sound>
largeIconEnabled>
<largeIcon></largeIcon>
<group></group>, </group>
<sound>false</sound>
largeIconEnabled>
<largeIcon></largeIcon>
<group>], [<group>_in Arbeit</group>, _in Arbeit], [<group>_in Arbeit</group>, _in Arbeit]]
replaceAll(text, '')
--> <?xml version='1.0' encoding='UTF-8'
<notificationIconType>BUILTIN</notificationIconType>
<notificationIcon>FLASH</notificationIcon>
<customNotificationIcon></customNotificationIcon>
<title></title>
<message></message>
<isGroupSummary>false</isGroupSummary>
<all>false</all>
</data>
it works better, but I get all <group></group> (empty!) also.(?s)<group>(.*?)</group>
What am I doing wrong?
thanks,
regards,