Find/Replace: Regular expression and XML-aware mode

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
HomeGoods
Posts: 86

Find/Replace: Regular expression and XML-aware mode

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: 2391

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

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: 86

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

Sat Nov 19, 2016 11:07 am

Now I've got it. Thanks!

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 2 guests