Find/Replace: Regular expression and XML-aware mode

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
HomeGoods
Posts: 87
Joined: Wed Feb 09, 2005 8:57 am

Find/Replace: Regular expression and XML-aware mode

Post by HomeGoods » Thu Nov 17, 2016 8:20 pm

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?

adrian
Posts: 2532
Joined: Tue May 17, 2005 4:01 pm

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

Post by adrian » Fri Nov 18, 2016 1:52 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

HomeGoods
Posts: 87
Joined: Wed Feb 09, 2005 8:57 am

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

Post by HomeGoods » Sat Nov 19, 2016 11:07 am

Now I've got it. Thanks!

Post Reply