C plus plus code to Extract/Replace String between two delimiters

This article shows the C plus plus (C++) code to extract/replace a sub-string between two delimiters or characters using find and substr functions.

Extract String between two delimiters

For example, if you want to extract the string between two delimiters “[” and “]” from Sri[nivas]an , then the CPP code will be

CPP output to extract a string between two delimiters
CPP code output to extract a string between two delimiters

Replace String between two delimiters

Below is the C plus plus code to replace string between two characters or delimiters within a string. Code replaces “nivasa” between delimiters “[” and “]” in “Sri[nivasa]n” with “vas”.

screenshot of result of replace string between delimiters or characters in c plus plus
result of replace string between delimiters or characters in c++

Check Extract string between two delimiters in Python

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published. Required fields are marked *