Negative logic
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 3
- Joined: Fri Oct 29, 2021 11:31 pm
Negative logic
I want to find text but exclude in the find certain text:
<tag>1234567890qwerty1234567890</tag>
<tag>1234567890qwerty1111117890</tag>
<tag>1234567890qwerty1234567890</tag>
<tag>1234567890qwerty1234567890</tag>
In my find I want to search for <tag>[^<>]+ NOT 111111</tag>
so my search only finds lines 1, 3, and 4.
Is there a way to do this?
<tag>1234567890qwerty1234567890</tag>
<tag>1234567890qwerty1111117890</tag>
<tag>1234567890qwerty1234567890</tag>
<tag>1234567890qwerty1234567890</tag>
In my find I want to search for <tag>[^<>]+ NOT 111111</tag>
so my search only finds lines 1, 3, and 4.
Is there a way to do this?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Negative logic
Hello,
I'm guessing you actually mean <tag>[^<>]+ NOT 1111117890</tag>
In that case it works with a regular expression like this (zero-width negative look-behind):
<tag>[^<>]+(?<!1111117890)</tag>
If you have wildcards on both sides of the negated string, it won't work.
e.g.
<tag>[^<>]+(?<!111111)[^<>]+</tag>
This may seem ok in theory, but it's not working in practice.
Regards,
Adrian
I'm guessing you actually mean <tag>[^<>]+ NOT 1111117890</tag>
In that case it works with a regular expression like this (zero-width negative look-behind):
<tag>[^<>]+(?<!1111117890)</tag>
If you have wildcards on both sides of the negated string, it won't work.
e.g.
<tag>[^<>]+(?<!111111)[^<>]+</tag>
This may seem ok in theory, but it's not working in practice.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Return to “General XML Questions”
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