Regex to replace hyphens between two numbers with commas
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 6
- Joined: Thu Dec 22, 2016 2:22 pm
Regex to replace hyphens between two numbers with commas
Hi there,
I have a text with numbers in between, the numbers should change from 9-3 into something like 9,3.
I can find the numbers with \d{1,2}[\*\-]{1}\d{1,2}
but how do I do the replacement?
Thanks for your help!
I have a text with numbers in between, the numbers should change from 9-3 into something like 9,3.
I can find the numbers with \d{1,2}[\*\-]{1}\d{1,2}
but how do I do the replacement?
Thanks for your help!
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Regex to replace hyphens between two numbers with commas
Hi,
You need to create groups using ( and ) for the text which will stay in place and then in the replace field use $1, $2, etc for the groups you want to keep.
So if you search for (\d{1,2})[\*\-]{1}(\d{1,2}) you can replace with $1,$2.
Regards,
Radu
You need to create groups using ( and ) for the text which will stay in place and then in the replace field use $1, $2, etc for the groups you want to keep.
So if you search for (\d{1,2})[\*\-]{1}(\d{1,2}) you can replace with $1,$2.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
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