regex not selecting last end of line
Questions about XML that are not covered by the other forums should go here.
regex not selecting last end of line
Hi, I want to delete (i.e. replace wiith nothing) the first three lines of this code
<row>
<entry namest="col1" nameend="col2"/>
</row>
<row>
and when I use this regex
<row>$\s*<entry namest="col1" nameend="col2"\/>$\s*<\/row>$\s
It doesn't select the final eol, so it ends up replacing the 3 unwanted lines with a blank line.
Any suggestions? Would also be open to something using xpath.
<row>
<entry namest="col1" nameend="col2"/>
</row>
<row>
and when I use this regex
<row>$\s*<entry namest="col1" nameend="col2"\/>$\s*<\/row>$\s
It doesn't select the final eol, so it ends up replacing the 3 unwanted lines with a blank line.
Any suggestions? Would also be open to something using xpath.
Re: regex not selecting last end of line
Hi,
I don't see a problem with the regex, it should also match the line break after the closing row tag. In Oxygen the line breaks in XML are strictly \n (a single whitespace).
You may want to also add ^\s* in front, so that it consumes the indent in front of the row start tag. Perhaps that's what you see at the end.
XPath would be: //row[entry[@namest="col1" and @nameend="col2"]]
But note that in case of XPath moreso you can't remove the trailing line break as it is outside of the row tags.
I don't see a problem with the regex, it should also match the line break after the closing row tag. In Oxygen the line breaks in XML are strictly \n (a single whitespace).
You may want to also add ^\s* in front, so that it consumes the indent in front of the row start tag. Perhaps that's what you see at the end.
XPath would be: //row[entry[@namest="col1" and @nameend="col2"]]
But note that in case of XPath moreso you can't remove the trailing line break as it is outside of the row tags.
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
Re: regex not selecting last end of line
To delete the first three lines of your XML code using a regex, you can use a regex that matches the lines and includes the newline characters at the end tiny fishing
Here's a refined regex that should work for you:
<row>\s*<entry namest="col1" nameend="col2"\s*/>\s*</row>\s*
This regex will match the entire block including the newline characters. If you are using a programming language or a tool that supports multi-line regex, ensure you have the multi-line mode enabled.
Here's a refined regex that should work for you:
<row>\s*<entry namest="col1" nameend="col2"\s*/>\s*</row>\s*
This regex will match the entire block including the newline characters. If you are using a programming language or a tool that supports multi-line regex, ensure you have the multi-line mode enabled.
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