Regex to match xrefs
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Regex to match xrefs
Hello,
I use the following grep command to find xref elements, whatever their reference filenames are.
This works well. However, when I want to use the expression solely in Oxygen, I don't get any results.
Any feedback is welcome. Thanks a lot
I use the following grep command to find xref elements, whatever their reference filenames are.
Code: Select all
grep -ri 'xref href="[^"]\+"/>' *
Code: Select all
xref href="[^"]\+"/>
image.png
Do you have any idea of the formatting or request to make it work?Any feedback is welcome. Thanks a lot

You do not have the required permissions to view the files attached to this post.
------
Gaspard
Gaspard
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Regex to match xrefs
Hi,
How about if you uncheck the "Enable XML search options" checkbox? Because this checkbox splits the XML content in intervals but your search string spans both element names and attribute values, so it's not something which for example matches just inside an attribute value.
Regards,
Radu
How about if you uncheck the "Enable XML search options" checkbox? Because this checkbox splits the XML content in intervals but your search string spans both element names and attribute values, so it's not something which for example matches just inside an attribute value.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Regex to match xrefs
Hi Radu
Thanks for your answer. Unselecting this option didn't help to retrieve the elements.
Even within a topic, it doesn't seem to work although I have one xref element under my eyes.
I'll continue looking if there are other options that could help.

Thanks for your answer. Unselecting this option didn't help to retrieve the elements.
Even within a topic, it doesn't seem to work although I have one xref element under my eyes.
I'll continue looking if there are other options that could help.
image.png
You do not have the required permissions to view the files attached to this post.
------
Gaspard
Gaspard
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Regex to match xrefs
Hi,
This works for me in Oxygen:
Your original attempt escaped the "\+" sign meaning that it was searched as a literal + sign.
Also why not search directly for "<xref" with or without regexp?
Regards,
Radu
This works for me in Oxygen:
Code: Select all
<xref href="[^"]+"/>
Also why not search directly for "<xref" with or without regexp?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Regex to match xrefs
Problem solved!
I used this expression and I deactivated the XML search options.
Thanks for your help
I used this expression
Code: Select all
xref href="[^"]+.dita"\>
Thanks for your help

------
Gaspard
Gaspard
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Regex to match xrefs
Post by chrispitude »
Hi gbv34,
You might want to test that on an <xref> that wraps within the element:
If that does not match, consider something like
as there can be cases where the opening tag and even the closing bracket can be word-wrapped onto another line (although perhaps not in your DITA source, but definitely in ours).
You might want to test that on an <xref> that wraps within the element:
Code: Select all
<xref
href="foo.dita"
/>
Code: Select all
xref\s+href="[^"]+.dita"\s*\>
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service