0

I have written a regex to match from locale="en" to date slot="164" but my regex is not matching multiple new lines. Please advice.

regex

locale="en"\s>\n<string slot="157">(.*|\n)*slot="164"

matching string

<case id="1" casebase="1" name="K" locale="en" >
<string slot="157"><value>1asw</value></string><enum slot="12"><value id="1" name="Incomplete" /></enum><integer slot="9963"><value>2</value>
</integer><string slot="9960"><value>
07/12/18 16:51  a created with status Incomplete by a &lt;br/&gt;

</value></string><string slot="9961"><value>awd</value></string><string slot="160"><value>awd</value></string><date slot="161"><value>2018-07-12T20:51:34</value>
</date><date slot="164"><value>2018-07-12T20:51:34</value>
</date></case>

suggested regex

skr
  • 1,700
  • 1
  • 15
  • 39
  • Use `(.*?)` with an appropriate modifier (or `([\s\S]*?)`) instead of a `(.*|\n)*`. – Wiktor Stribiżew Aug 01 '19 at 08:46
  • @WiktorStribiżew I tried your suggestion but that doesn't seem to work. Attached screenshot. – skr Aug 01 '19 at 09:13
  • You did not use ***my*** suggestion. `locale="en"\s>\n(.*?)slot="164"` is what I suggested (with *`.` Can Match Newline Characters* option ON). – Wiktor Stribiżew Aug 01 '19 at 09:14
  • It's not matching till the slot I want to , it's matching only first two lines. – skr Aug 01 '19 at 09:14
  • See [this demo](https://regex101.com/r/PFq3d0/1), the solution works well. – Wiktor Stribiżew Aug 01 '19 at 09:16
  • @WiktorStribiżew, Thank you for quick reponse , yes it does work on the website you have used for the demo, it worked for me too earlier but the same is not working in Notepad++ or emeditor. I am not able to understand the difference. – skr Aug 01 '19 at 09:20
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/197332/discussion-between-skr-and-wiktor-stribizew). – skr Aug 01 '19 at 09:25
  • `locale="en"\s>\n(.*?)slot="164"` works in Notepad++ with *`.` matches newline*. It works everywhere with the right option turned on. – Wiktor Stribiżew Aug 01 '19 at 09:31

0 Answers0