Page 1 of 1

Find/Replace: Regular expression and XML-aware mode

Posted: Thu Nov 17, 2016 8:20 pm
by HomeGoods
Suppose I have this XML document opened in Text mode

Code: Select all

<e>
<e bar="foo bar" />
<e bar="bar baz" />
<e baz="baz qux" />
</e>
and want to find and highlight the value of @bar that starts with 'b'; namely "bar baz" of the 2nd @bar.
I opened the Find/Replace dialog and set these options:
  • Find: ^b.*
  • XPath: @bar
  • Enable [Regular expression]
  • Enable [Enable XML search options] and [Attribute values]
But nothing's found. Looks like '^' in the regular expression doesn't work.
What's the correct syntax to accomplish the task?

Re: Find/Replace: Regular expression and XML-aware mode

Posted: Fri Nov 18, 2016 1:52 pm
by adrian
HI,

This doesn't work because Oxygen always treats "^" as the line start, not a region start.
You can work around this with zero-width negative lookbehind:
Find: (?<!.)b.*

Regards,
Adrian

Re: Find/Replace: Regular expression and XML-aware mode

Posted: Sat Nov 19, 2016 11:07 am
by HomeGoods
Now I've got it. Thanks!